Commit 37bd2417 authored by Colin Watson's avatar Colin Watson

Use check_lists to check Translation files rather than a similar custom...

Use check_lists to check Translation files rather than a similar custom function; this allows use of stronger hashes.
parent 29bd24e0
...@@ -3,6 +3,8 @@ debmirror (1:2.21) UNRELEASED; urgency=medium ...@@ -3,6 +3,8 @@ debmirror (1:2.21) UNRELEASED; urgency=medium
* Generate trace file using LC_ALL=C (closes: #817721). * Generate trace file using LC_ALL=C (closes: #817721).
* Prefer xz over gz, and cope with either being missing as long as we can * Prefer xz over gz, and cope with either being missing as long as we can
get some version of the index file in question. get some version of the index file in question.
* Use check_lists to check Translation files rather than a similar custom
function; this allows use of stronger hashes.
-- Colin Watson <cjwatson@debian.org> Wed, 09 Mar 2016 21:27:40 +0000 -- Colin Watson <cjwatson@debian.org> Wed, 09 Mar 2016 21:27:40 +0000
......
...@@ -1681,21 +1681,6 @@ sub check_file { ...@@ -1681,21 +1681,6 @@ sub check_file {
return 0; return 0;
} }
# Always checks both file size and sha1 as the files get updated (this is
# similar to what is done in check_lists, which forces verify_checksums).
sub check_i18n {
my ($filename, $size, $sha1)=@_;
my $digest = Digest::SHA->new(1);
my $ret = 0;
if (-f "$filename" and ($size == -s _)) {
open HANDLE, $filename or die "$filename: $!";
$digest->addfile(*HANDLE);
$ret = ($sha1 eq $digest->hexdigest);
}
return $ret;
}
# Check uncompressed diff content against sha1sum from Index file. # Check uncompressed diff content against sha1sum from Index file.
sub check_diff { sub check_diff {
my ($filename, $size, $sha1) = @_; my ($filename, $size, $sha1) = @_;
...@@ -2483,7 +2468,6 @@ sub i18n_from_release { ...@@ -2483,7 +2468,6 @@ sub i18n_from_release {
my $filename = substr($path, length($compdir)+1, length($path)-length($compdir)-1); my $filename = substr($path, length($compdir)+1, length($path)-length($compdir)-1);
next if $filename !~ /bz2$/; next if $filename !~ /bz2$/;
my ($sha1, $size) = ($file_lists{$path}{SHA1}, $file_lists{$path}{size});
if(!(defined($include) && ($subdir."/".$filename)=~/$include/o)) { if(!(defined($include) && ($subdir."/".$filename)=~/$include/o)) {
next if (defined($exclude) && ($subdir."/".$filename)=~/$exclude/o); next if (defined($exclude) && ($subdir."/".$filename)=~/$exclude/o);
} }
...@@ -2491,10 +2475,8 @@ sub i18n_from_release { ...@@ -2491,10 +2475,8 @@ sub i18n_from_release {
$files{"$subdir/$filename"}=1; $files{"$subdir/$filename"}=1;
$files{$tempdir."/"."$subdir/$filename"}=1; $files{$tempdir."/"."$subdir/$filename"}=1;
if (! check_i18n("$tempdir/$subdir/$filename", $size, $sha1)) { if (! check_lists($path)) {
$bytes_to_get += $size; $bytes_to_get += $file_lists{$path}{size};
$i18n_get{"$subdir/$filename"}{sha1} = $sha1;
$i18n_get{"$subdir/$filename"}{size} = $size;
$i18n_get{"$subdir/$filename"}{dist} = $dist; $i18n_get{"$subdir/$filename"}{dist} = $dist;
$i18n_get{"$subdir/$filename"}{distpath} = $distpath; $i18n_get{"$subdir/$filename"}{distpath} = $distpath;
$i18n_get{"$subdir/$filename"}{filename} = $filename; $i18n_get{"$subdir/$filename"}{filename} = $filename;
...@@ -2505,7 +2487,7 @@ sub i18n_from_release { ...@@ -2505,7 +2487,7 @@ sub i18n_from_release {
sub get_i18n_files { sub get_i18n_files {
say("Get Translation files ..."); say("Get Translation files ...");
foreach my $file (sort keys %i18n_get) { foreach my $file (sort keys %i18n_get) {
if (! check_i18n("$tempdir/$file", $i18n_get{$file}{size}, $i18n_get{$file}{sha1})) { if (! check_lists("$tempdir/$file")) {
remote_get("$file"); remote_get("$file");
if ($debmarshal) { if ($debmarshal) {
link_auxfile_into_snapshot($file, link_auxfile_into_snapshot($file,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment