The following commit has been merged in the master branch:
commit c1e19f3274545cd72ffefed29a88452d866110e9
Author: Guillem Jover <[email protected]>
Date:   Sat Jul 28 03:30:50 2012 +0200

    dpkg: Defer cleanup of .dpkg-new and .dpkg-tmp paths on removal
    
    Clean them up only when we are definitely removing the main path.

diff --git a/debian/changelog b/debian/changelog
index 9d052aa..6ded7a5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -64,6 +64,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low
     now resets holds among others. Closes: #163763
   * Always reset want status when installing a package; so this now resets
     holds among others. Closes: #162541
+  * Defer cleanup of .dpkg-new and .dpkg-tmp paths on removal to the point
+    when we are definitely removing the main path.
 
  -- Guillem Jover <[email protected]>  Fri, 03 Aug 2012 13:21:00 +0200
 
diff --git a/src/remove.c b/src/remove.c
index 06d2c95..4267705 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -285,21 +285,6 @@ removal_bulk_remove_files(struct pkginfo *pkg)
 
       trig_file_activate(usenode, pkg);
 
-      varbuf_trunc(&fnvb, before);
-      varbuf_add_str(&fnvb, DPKGTEMPEXT);
-      varbuf_end_str(&fnvb);
-      debug(dbg_eachfiledetail, "removal_bulk cleaning temp '%s'", fnvb.buf);
-
-      ensure_pathname_nonexisting(fnvb.buf);
-
-      varbuf_trunc(&fnvb, before);
-      varbuf_add_str(&fnvb, DPKGNEWEXT);
-      varbuf_end_str(&fnvb);
-      debug(dbg_eachfiledetail, "removal_bulk cleaning new '%s'", fnvb.buf);
-      ensure_pathname_nonexisting(fnvb.buf);
-
-      varbuf_trunc(&fnvb, before);
-      varbuf_end_str(&fnvb);
       if (is_dir) {
         debug(dbg_eachfiledetail, "removal_bulk is a directory");
         /* Only delete a directory or a link to one if we're the only
@@ -316,6 +301,22 @@ removal_bulk_remove_files(struct pkginfo *pkg)
         if (dir_is_used_by_others(namenode, pkg))
           continue;
       }
+
+      varbuf_trunc(&fnvb, before);
+      varbuf_add_str(&fnvb, DPKGTEMPEXT);
+      varbuf_end_str(&fnvb);
+      debug(dbg_eachfiledetail, "removal_bulk cleaning temp '%s'", fnvb.buf);
+      ensure_pathname_nonexisting(fnvb.buf);
+
+      varbuf_trunc(&fnvb, before);
+      varbuf_add_str(&fnvb, DPKGNEWEXT);
+      varbuf_end_str(&fnvb);
+      debug(dbg_eachfiledetail, "removal_bulk cleaning new '%s'", fnvb.buf);
+      ensure_pathname_nonexisting(fnvb.buf);
+
+      varbuf_trunc(&fnvb, before);
+      varbuf_end_str(&fnvb);
+
       debug(dbg_eachfiledetail, "removal_bulk removing '%s'", fnvb.buf);
       if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
       if (errno == ENOTEMPTY || errno == EEXIST) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to