better check of md5sum files
authorDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Mon, 21 May 2012 09:00:07 +0000 (11:00 +0200)
committerDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Mon, 21 May 2012 09:00:07 +0000 (11:00 +0200)
lib/CloudStore/Store.pm

index 1956a73..3969c48 100644 (file)
@@ -327,8 +327,8 @@ sub md5pool {
        my $md5 = $data->{md5} || die "no md5 in ",dump $data;
        my $path = $self->blob_path($data);
 
-       if ( ! -e $path ) {
-               warn "ERROR missing path $path";
+       if ( ! -f $path ) {
+               warn "ERROR missing path $path: $!";
                return;
        }
 
@@ -377,8 +377,8 @@ sub dedup {
                while(<$md5sum>) {
                        chomp;
                        my ( $md5, $file ) = split(/\s+/,$_,2);
-                       if ( ! $file ) {
-                               warn "IGNORE $md5 without file\n";
+                       if ( $md5 !~ /^[0-9a-f]{32}$/i || ! $file ) {
+                               warn "ERROR corrupt md5sum line ",dump($_);
                                next;
                        }
                        if ( ! -e "$self->{md5pool}/$md5" ) {