summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2012-07-14 09:51:19 +0200
committerDaniel Friesel <derf@finalrewind.org>2012-07-14 09:51:19 +0200
commit0e96a7165de21a1e14d106224ab41d58a1b65db1 (patch)
tree7f05ca561f16a3df65be1b7587ca528fc5e2f47a
parent7cc60cd4f505634fd1d4cdb052ceb1769be4e3a0 (diff)
save database version, just to be safe
-rw-r--r--.gitignore1
-rw-r--r--Changelog4
-rwxr-xr-xbin/hashl3
-rw-r--r--lib/App/Hashl.pm13
4 files changed, 19 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index aea8739..229189a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@
/MANIFEST.bak
/MANIFEST.SKIP
/MANIFEST.SKIP.bak
+/MYMETA.json
/MYMETA.yml
diff --git a/Changelog b/Changelog
index c2d219a..28bdb40 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+git HEAD
+
+ * Set read size to 0 (zero) to hash whole files
+
hashl 1.00 - Wed Nov 02 2011
* Add "hashl list <regex>" to filter listed files by name
diff --git a/bin/hashl b/bin/hashl
index 5d1f522..1d53691 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -127,9 +127,10 @@ sub db_find_known {
}
sub db_info {
+ printf( "Database created by hashl v%s\n", $hashl->db_version, );
printf(
"Read size: %d bytes (%s)\n",
- $hashl->read_size(), $hashl->si_size( $hashl->read_size ),
+ $hashl->read_size, $hashl->si_size( $hashl->read_size ),
);
return;
diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm
index ec779a9..dc5fca5 100644
--- a/lib/App/Hashl.pm
+++ b/lib/App/Hashl.pm
@@ -19,6 +19,7 @@ sub new {
$ref->{config} = \%conf;
$ref->{config}->{read_size} //= ( 2**20 ) * 4; # 4 MiB
+ $ref->{version} = $VERSION;
return bless( $ref, $obj );
}
@@ -28,6 +29,10 @@ sub new_from_file {
my $ref = retrieve($file);
+ if ( not defined $ref->{version} ) {
+ $ref->{version} = '1.00';
+ }
+
return bless( $ref, $obj );
}
@@ -52,7 +57,7 @@ sub hash_file {
if ( ( stat($file) )[7] == 0 ) {
return $digest->hexdigest;
}
- if ($self->{config}->{read_size} == 0) {
+ if ( $self->{config}->{read_size} == 0 ) {
$digest->addfile($file);
return $digest->hexdigest;
}
@@ -102,6 +107,12 @@ sub read_size {
return $self->{config}->{read_size};
}
+sub db_version {
+ my ($self) = @_;
+
+ return $self->{version};
+}
+
sub file {
my ( $self, $name ) = @_;