From 3f1d27c4a43492cf2ea379d8a4bea37aa18e3201 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 2 Nov 2011 10:31:45 +0100 Subject: Fix handling of zero-length files (closes #1) --- lib/App/Hashl.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/App/Hashl.pm') diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm index 1f43060..2c382ea 100644 --- a/lib/App/Hashl.pm +++ b/lib/App/Hashl.pm @@ -47,6 +47,11 @@ sub hash_file { my ( $self, $file ) = @_; my $data; + # read() fails for empty files + if ( ( stat($file) )[7] == 0 ) { + return sha1_hex(); + } + #<<< perltidy has problems indenting 'or die' with tabs open( my $fh, '<', $file ) -- cgit v1.2.3