diff options
author | Daniel Friesel <derf@finalrewind.org> | 2012-07-14 09:51:19 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2012-07-14 09:51:19 +0200 |
commit | 0e96a7165de21a1e14d106224ab41d58a1b65db1 (patch) | |
tree | 7f05ca561f16a3df65be1b7587ca528fc5e2f47a | |
parent | 7cc60cd4f505634fd1d4cdb052ceb1769be4e3a0 (diff) |
save database version, just to be safe
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Changelog | 4 | ||||
-rwxr-xr-x | bin/hashl | 3 | ||||
-rw-r--r-- | lib/App/Hashl.pm | 13 |
4 files changed, 19 insertions, 2 deletions
@@ -6,4 +6,5 @@ /MANIFEST.bak /MANIFEST.SKIP /MANIFEST.SKIP.bak +/MYMETA.json /MYMETA.yml @@ -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 @@ -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 ) = @_; |