summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2022-04-24 00:24:40 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2024-11-22 12:21:24 +0000
commit370e024224b8116840173201d51c0c2a170e0e93 (patch)
tree567f548125e1e3c6d5c68e8e0960eadf8a5b5cf0
parent496c8b4191790231258e644ac8cd4096d54f445f (diff)
Alternatively calculate alternative file hashes in file method
If we do not have the requested file we haven't calculated the hashes for it either and it is likely that the alternative file will be used, so to save the main thread from being busy with calculating hashes we do the calculation here in the method.
-rw-r--r--methods/file.cc2
-rwxr-xr-xtest/integration/test-apt-update-incomplete-file-mirror3
2 files changed, 4 insertions, 1 deletions
diff --git a/methods/file.cc b/methods/file.cc
index b2fe133f2..ff93f83d0 100644
--- a/methods/file.cc
+++ b/methods/file.cc
@@ -107,6 +107,8 @@ bool FileMethod::Fetch(FetchItem *Itm)
AltRes.IMSHit = false;
if (Itm->LastModified == Buf.st_mtime && Itm->LastModified != 0)
AltRes.IMSHit = true;
+ if (Res.Filename.empty())
+ CalculateHashes(Itm, AltRes);
break;
}
// no break here as we could have situations similar to '.gz' vs '.tar.gz' here
diff --git a/test/integration/test-apt-update-incomplete-file-mirror b/test/integration/test-apt-update-incomplete-file-mirror
index 86eb890a7..2d2125582 100755
--- a/test/integration/test-apt-update-incomplete-file-mirror
+++ b/test/integration/test-apt-update-incomplete-file-mirror
@@ -28,5 +28,6 @@ rm -rf rootdir/var/lib/apt/lists
find aptarchive/dists -name 'Packages' | while read FILE; do
echo 'hacked' > $FILE
done
-testfailure apt update
+testfailure apt update -o Debug::pkgAcquire::Worker=1
testsuccessequal '4' grep -c -- '- Filesize:' rootdir/tmp/testfailure.output
+testsuccessequal '2' grep -c '%0aAlt-Checksum-FileSize-Hash:%20' rootdir/tmp/testfailure.output