summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}