From 7ca83492e802967f183babf06ab541b1b51f1703 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 19 Jan 2017 03:57:45 +0100 Subject: remove 'old' FAILED files in the next acquire call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apt-pkg/acquire.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg') 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) -- cgit v1.2.3