Only rename StatError files in AbortTransaction()
authorMichael Vogt <mvo@debian.org>
Wed, 8 Oct 2014 18:13:56 +0000 (20:13 +0200)
committerMichael Vogt <mvo@debian.org>
Wed, 8 Oct 2014 18:13:56 +0000 (20:13 +0200)
This fixes a race that we see in travis when two copy operations
finish at about the same time but the bad one first. This lead to
a rename of the good one and triggers a error when apt tries to
verify the good version but can no longer find it.

apt-pkg/acquire-item.cc

index 1ff3e32..604a2e0 100644 (file)
@@ -1545,10 +1545,13 @@ void pkgAcqMetaBase::AbortTransaction()
       if ((*I)->Status == pkgAcquire::Item::StatIdle)
          (*I)->Status = pkgAcquire::Item::StatDone;
 
-      // kill files in partial
-      std::string const PartialFile = GetPartialFileName(flNotDir((*I)->DestFile));
-      if(FileExists(PartialFile))
-         Rename(PartialFile, PartialFile + ".FAILED");
+      // kill failed files in partial
+      if ((*I)->Status == pkgAcquire::Item::StatError)
+      {
+         std::string const PartialFile = GetPartialFileName(flNotDir((*I)->DestFile));
+         if(FileExists(PartialFile))
+            Rename(PartialFile, PartialFile + ".FAILED");
+      }
    }
 }
                                                                        /*}}}*/