]> git.saurik.com Git - apt.git/commitdiff
remove uncompressed leftover partial file before pdiff bootstrap
authorDavid Kalnischkies <david@kalnischkies.de>
Fri, 8 Jan 2016 16:51:23 +0000 (17:51 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Fri, 8 Jan 2016 16:51:23 +0000 (17:51 +0100)
The code already deals with compressed leftovers, but forgot the
uncompressed files. The opertunity is picked to reorder this code and
add debug messages about the actions taken as well as produce such a
leftover file in the associated testcase.

apt-pkg/acquire-item.cc
test/integration/test-pdiff-usage

index b73c4985f0d4dd3ad446a3e9e4fe8840a5ec29a8..446551cc2ee1a7c8bf38fa7d00599f27c91b2e60 100644 (file)
@@ -2103,22 +2103,35 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile)       /*{{{*/
 
    // clean the plate
    {
 
    // clean the plate
    {
+      std::string const Final = GetExistingFilename(CurrentPackagesFile);
+      if (unlikely(Final.empty())) // because we wouldn't be called in such a case
+        return false;
       std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
       std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
-      std::vector<std::string> exts = APT::Configuration::getCompressorExtensions();
-      for (auto const &ext : exts)
+      if (FileExists(PartialFile) && RemoveFile("Bootstrap-linking", PartialFile) == false)
+      {
+        if (Debug)
+           std::clog << "Bootstrap-linking for patching " << CurrentPackagesFile
+              << " by removing stale " << PartialFile << " failed!" << std::endl;
+        return false;
+      }
+      for (auto const &ext : APT::Configuration::getCompressorExtensions())
       {
         std::string const Partial = PartialFile + ext;
       {
         std::string const Partial = PartialFile + ext;
-        if (FileExists(Partial))
-           RemoveFile("PDiffs-Bootstrap", Partial);
+        if (FileExists(Partial) && RemoveFile("Bootstrap-linking", Partial) == false)
+        {
+           if (Debug)
+              std::clog << "Bootstrap-linking for patching " << CurrentPackagesFile
+                 << " by removing stale " << Partial << " failed!" << std::endl;
+           return false;
+        }
       }
       }
-      std::string const Final = GetExistingFilename(CurrentPackagesFile);
-      if (unlikely(Final.empty())) // because we wouldn't be called in such a case
-        return false;
       std::string const Ext = Final.substr(CurrentPackagesFile.length());
       std::string const Partial = PartialFile + Ext;
       if (symlink(Final.c_str(), Partial.c_str()) != 0)
       {
       std::string const Ext = Final.substr(CurrentPackagesFile.length());
       std::string const Partial = PartialFile + Ext;
       if (symlink(Final.c_str(), Partial.c_str()) != 0)
       {
-        std::clog << "Bootstrap-linking for patching " << CurrentPackagesFile << " by linking " << Final << " to " << Partial << " failed!" << std::endl;
+        if (Debug)
+           std::clog << "Bootstrap-linking for patching " << CurrentPackagesFile
+              << " by linking " << Final << " to " << Partial << " failed!" << std::endl;
         return false;
       }
    }
         return false;
       }
    }
index bf7779e4031b58c2a0affd34cce536baea0b30c0..253abb92cf7841519f5bcfb3be82e5fc6536730d 100755 (executable)
@@ -60,6 +60,9 @@ testrun() {
 " aptcache show apt oldstuff
        configcompression '.' 'gz'
 
 " aptcache show apt oldstuff
        configcompression '.' 'gz'
 
+       # see if the code deals properly with leftover partial files
+       touch rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages
+
        msgmsg "Testcase: apply with one patch: $*"
        find aptarchive -name 'Packages*' -type f -delete
        cp "${PKGFILE}-new" aptarchive/Packages
        msgmsg "Testcase: apply with one patch: $*"
        find aptarchive -name 'Packages*' -type f -delete
        cp "${PKGFILE}-new" aptarchive/Packages
@@ -208,6 +211,9 @@ SHA256-Download:
        msgmsg "Testcase: pdiff patch bigger than index itself: $*"
        rm -rf rootdir/var/lib/apt/lists
        cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
        msgmsg "Testcase: pdiff patch bigger than index itself: $*"
        rm -rf rootdir/var/lib/apt/lists
        cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
+       # the general testcode checks for leftovers in partial, but as this file
+       # is never touched in this test as it exits earlier its not a leftover…
+       rm -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages
        cp "${PKGFILE}-new" aptarchive/Packages
        compressfile 'aptarchive/Packages'
        mkdir -p aptarchive/Packages.diff
        cp "${PKGFILE}-new" aptarchive/Packages
        compressfile 'aptarchive/Packages'
        mkdir -p aptarchive/Packages.diff