From: David Kalnischkies Date: Tue, 5 Jan 2016 23:08:04 +0000 (+0100) Subject: ensure compression cleanup even without lists-cleanup X-Git-Tag: 1.2_exp1~15 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/1866240123a57de8f693b0ba01d8b709f027282d?ds=inline;hp=--cc ensure compression cleanup even without lists-cleanup If we store files compressed in lists/ and the file switched compression formats we happened to retain the "old" format, but by default the cleanup process catched this oversight and removed the file. [The initial situation described doesn't arise as we store no files by default compressed and even with apt-file configuring Contents files, we don't really have that problem as there is just .gz files for those.] We solve this by just removing any uncompressed as well as compressed (we support) file just before we move the 'new' version of the file in. --- 1866240123a57de8f693b0ba01d8b709f027282d diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 6b0debb44..02beb9bbf 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -388,16 +388,43 @@ bool pkgAcqTransactionItem::TransactionState(TransactionStates const state) } break; case TransactionCommit: - if(PartialFile != "") + if(PartialFile.empty() == false) { - if(Debug == true) - std::clog << "mv " << PartialFile << " -> "<< DestFile << " # " << DescURI() << std::endl; + if (PartialFile != DestFile) + { + // ensure that even without lists-cleanup all compressions are nuked + std::string FinalFile = GetFinalFileNameFromURI(Target.URI); + if (FileExists(FinalFile)) + { + if(Debug == true) + std::clog << "rm " << FinalFile << " # " << DescURI() << std::endl; + if (RemoveFile("TransactionStates-Cleanup", FinalFile) == false) + return false; + } + for (auto const &ext: APT::Configuration::getCompressorExtensions()) + { + auto const Final = FinalFile + ext; + if (FileExists(Final)) + { + if(Debug == true) + std::clog << "rm " << Final << " # " << DescURI() << std::endl; + if (RemoveFile("TransactionStates-Cleanup", Final) == false) + return false; + } + } + if(Debug == true) + std::clog << "mv " << PartialFile << " -> "<< DestFile << " # " << DescURI() << std::endl; + if (Rename(PartialFile, DestFile) == false) + return false; + } + else if(Debug == true) + std::clog << "keep " << PartialFile << " # " << DescURI() << std::endl; - Rename(PartialFile, DestFile); } else { if(Debug == true) std::clog << "rm " << DestFile << " # " << DescURI() << std::endl; - RemoveFile("TransactionCommit", DestFile); + if (RemoveFile("TransactionCommit", DestFile) == false) + return false; } break; }