diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-01-10 14:26:38 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-01-10 14:44:46 +0000 |
commit | 2ad8f4f37376e982077ccdaaa13cdcc6b8da0705 (patch) | |
tree | 5bd9377ebfb6e396bae7e45982d8e2eea8977d4a /dgit | |
parent | f8b6719127ece2bdf5d26c85a5f35060a4222b70 (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-x | dgit | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -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; } |