From 0e96a7165de21a1e14d106224ab41d58a1b65db1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 14 Jul 2012 09:51:19 +0200 Subject: save database version, just to be safe --- lib/App/Hashl.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/App/Hashl.pm') 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 ) = @_; -- cgit v1.2.3