chiark / gitweb /
dgit: complete_file_from_dsc: Introduce $checkhash
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Jan 2017 14:26:38 +0000 (14:26 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Jan 2017 14:44:46 +0000 (14:44 +0000)
No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 135abe5fd1b69291af30d5b2740840c01bbe797c..39d439db059ca0f834bbe29223aabf71f3c16076 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2465,6 +2465,19 @@ sub complete_file_from_dsc ($$) {
     my $tf = "$dstdir/$f";
     my $downloaded = 0;
 
     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 {
     if (stat_exists $tf) {
        progress "using existing $f";
     } else {
@@ -2479,16 +2492,7 @@ sub complete_file_from_dsc ($$) {
        $downloaded = 1;
     }
 
        $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;
 }
 
     return 1;
 }