summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-01-19 03:57:45 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-01-19 03:57:45 +0100
commit7ca83492e802967f183babf06ab541b1b51f1703 (patch)
tree6da3a2ea1d9ae32f7a64f254837936fe477b4341
parent3313eaf97c83177433478505c05815ab02f9782b (diff)
remove 'old' FAILED files in the next acquire call
If apt renames a file to .FAILED it leaves its namespace and is never touched again – expect since 1.1~exp4 in which "apt clean" will remove those files. The usefulness of these files rapidly degrades if you don't keep the update log itself (together with debug output in the best case) through and on 99% of all system they will be kept around forever just to collect dust over time and eat up space. With this commit an update call will remove all FAILED files of previous runs, so that the FAILED files you have on disk are always only the ones related to the last apt run stopping apt from hoarding files. Closes: 846476
-rw-r--r--apt-pkg/acquire.cc6
-rwxr-xr-xtest/integration/test-apt-update-expected-size4
2 files changed, 10 insertions, 0 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index ac925e72e..5c195786b 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -117,6 +117,12 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const
if (chmod(partial.c_str(), 0700) != 0)
_error->WarningE("SetupAPTPartialDirectory", "chmod 0700 of directory %s failed", partial.c_str());
+ _error->PushToStack();
+ // remove 'old' FAILED files to stop us from collecting them for no reason
+ for (auto const &Failed: GetListOfFilesInDir(partial, "FAILED", false, false))
+ RemoveFile("SetupAPTPartialDirectory", Failed);
+ _error->RevertToStack();
+
return true;
}
bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock)
diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size
index f7b825d98..710d05d18 100755
--- a/test/integration/test-apt-update-expected-size
+++ b/test/integration/test-apt-update-expected-size
@@ -25,6 +25,7 @@ test_inreleasetoobig() {
rm -f update.output
# ensure the failed InRelease file got renamed
testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
+ testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
}
test_packagestoobig() {
@@ -40,6 +41,8 @@ test_packagestoobig() {
NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz Writing more data than expected ($NEW_SIZE > $SIZE)
E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
+ testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED
+ testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
}
methodtest() {
@@ -51,6 +54,7 @@ methodtest() {
rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
# normal update works fine
testsuccess aptget update
+ touch rootdir/var/lib/apt/lists/partial/Old.FAILED
mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
# starting fresh works