From 947ae4b0f64218e6fba9dd7bd368f92e490c596d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 23 Feb 2013 09:15:49 +0000 Subject: [PATCH] httpfile: correct FILE_MISSING check in digest_mgmt This is unlikely to be an issue in fsck, fsck checks file size/existence before digesting the file. --- lib/MogileFS/HTTPFile.pm | 7 +++---- t/40-httpfile.t | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/MogileFS/HTTPFile.pm b/lib/MogileFS/HTTPFile.pm index 01c3632..4f1370f 100644 --- a/lib/MogileFS/HTTPFile.pm +++ b/lib/MogileFS/HTTPFile.pm @@ -204,15 +204,14 @@ retry: } elsif ($rv =~ /^\Q$uri\E \Q$alg\E=([a-f0-9]{32,128})\r\n/) { my $hexdigest = $1; - if ($hexdigest eq FILE_MISSING) { - # FIXME, this could be another error like EMFILE/ENFILE - return FILE_MISSING; - } my $checksum = eval { MogileFS::Checksum->from_string(0, "$alg:$hexdigest") }; return undeferr("$alg failed for $uri: $@") if $@; return $checksum->{checksum}; + } elsif ($rv =~ /^\Q$uri\E \Q$alg\E=-1\r\n/) { + # FIXME, this could be another error like EMFILE/ENFILE + return FILE_MISSING; } elsif ($rv =~ /^ERROR /) { return; # old server, fallback to HTTP } diff --git a/t/40-httpfile.t b/t/40-httpfile.t index 7fed6d7..ddcfa51 100644 --- a/t/40-httpfile.t +++ b/t/40-httpfile.t @@ -126,4 +126,8 @@ ok($size == $file->size, "big file size match $size"); ok($file->digest_mgmt('MD5', sub {}) eq $expect, "digest_mgmt('MD5') on big file"); ok($file->digest_http('MD5', sub {}) eq $expect, "digest_http('MD5') on big file"); +ok($file->delete, "file deleted"); +is(-1, $file->digest_http('MD5', sub {}), "digest_http detected missing"); +is(-1, $file->digest_mgmt('MD5', sub {}), "digest_mgmt detected missing"); + done_testing(); -- 2.11.4.GIT