summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-10 14:26:38 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-10 14:44:46 +0000
commit2ad8f4f37376e982077ccdaaa13cdcc6b8da0705 (patch)
tree5bd9377ebfb6e396bae7e45982d8e2eea8977d4a /dgit
parentf8b6719127ece2bdf5d26c85a5f35060a4222b70 (diff)
dgit: complete_file_from_dsc: Introduce $checkhash
No functional change. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit24
1 files changed, 14 insertions, 10 deletions
diff --git a/dgit b/dgit
index 135abe5..39d439d 100755
--- a/dgit
+++ b/dgit
@@ -2465,6 +2465,19 @@ sub complete_file_from_dsc ($$) {
my $tf = "$dstdir/$f";
my $downloaded = 0;
+ my $checkhash = sub {
+ open F, "<", "$tf" or die "$tf: $!";
+ $fi->{Digester}->reset();
+ $fi->{Digester}->addfile(*F);
+ F->error and die $!;
+ my $got = $fi->{Digester}->hexdigest();
+ $got eq $fi->{Hash} or
+ fail "file $f has hash $got but .dsc".
+ " demands hash $fi->{Hash} ".
+ ($downloaded ? "(got wrong file from archive!)"
+ : "(perhaps you should delete this file?)");
+ };
+
if (stat_exists $tf) {
progress "using existing $f";
} else {
@@ -2479,16 +2492,7 @@ sub complete_file_from_dsc ($$) {
$downloaded = 1;
}
- open F, "<", "$tf" or die "$tf: $!";
- $fi->{Digester}->reset();
- $fi->{Digester}->addfile(*F);
- F->error and die $!;
- my $got = $fi->{Digester}->hexdigest();
- $got eq $fi->{Hash} or
- fail "file $f has hash $got but .dsc".
- " demands hash $fi->{Hash} ".
- ($downloaded ? "(got wrong file from archive!)"
- : "(perhaps you should delete this file?)");
+ $checkhash->();
return 1;
}