From: David Kalnischkies Date: Tue, 19 May 2015 08:40:55 +0000 (+0200) Subject: don't try other compressions on hashsum mismatch X-Git-Tag: 1.1.exp9~140^2~30 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/58702f8563a443a7c6e66253b259c2488b877290 don't try other compressions on hashsum mismatch If we e.g. fail on hash verification for Packages.xz its highly unlikely that it will be any better with Packages.gz, so we just waste download bandwidth and time. It also causes us always to fallback to the uncompressed Packages file for which the error will finally be reported, which in turn confuses users as the file usually doesn't exist on the mirrors, so a bug in apt is suspected for even trying it… --- diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 8155b9bfe..cf89717c4 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -154,7 +154,18 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf) return; } - Status = StatError; + switch (Status) + { + case StatIdle: + case StatFetching: + case StatDone: + Status = StatError; + break; + case StatAuthError: + case StatError: + case StatTransientNetworkError: + break; + } Complete = false; Dequeue(); } @@ -167,7 +178,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf) RenameOnError(MaximumSizeExceeded); // report mirror failure back to LP if we actually use a mirror - if(FailReason.size() != 0) + if(FailReason.empty() == false) ReportMirrorFailure(FailReason); else ReportMirrorFailure(ErrorText); @@ -1403,17 +1414,19 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { Item::Failed(Message,Cnf); - size_t const nextExt = CompressionExtensions.find(' '); - if (nextExt != std::string::npos) + // authorisation matches will not be fixed by other compression types + if (Status != StatAuthError) { - CompressionExtensions = CompressionExtensions.substr(nextExt+1); - Init(RealURI, Desc.Description, Desc.ShortDesc); - Status = StatIdle; - return; + size_t const nextExt = CompressionExtensions.find(' '); + if (nextExt != std::string::npos) + { + CompressionExtensions = CompressionExtensions.substr(nextExt+1); + Init(RealURI, Desc.Description, Desc.ShortDesc); + Status = StatIdle; + return; + } } - Item::Failed(Message,Cnf); - if(Target->IsOptional() && ExpectedHashes.empty() && Stage == STAGE_DOWNLOAD) Status = StatDone; else diff --git a/test/integration/test-apt-update-not-modified b/test/integration/test-apt-update-not-modified index b1d55c156..bac33d531 100755 --- a/test/integration/test-apt-update-not-modified +++ b/test/integration/test-apt-update-not-modified @@ -14,6 +14,7 @@ setupaptarchive --no-update methodtest() { msgmsg 'Test InRelease with' "$1" rm -rf rootdir/var/lib/apt/lists + cp -a aptarchive/dists aptarchive/dists.good # get our cache populated testsuccess aptget update listcurrentlistsdirectory > listsdir.lst @@ -30,8 +31,27 @@ Reading package lists..." aptget update Reading package lists..." aptget update testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" - # readd arch so its downloaded again + # readd arch so its downloaded again… configarchitecture 'amd64' 'i386' + # … but oh noes, hashsum mismatch! + find aptarchive/dists/unstable/main/binary-amd64/ -type f -delete + cat >> aptarchive/dists/unstable/main/binary-amd64/Packages < "$1" < listsdir.lst redatereleasefiles '+1hour' testrun 'listsdir.lst'