Просмотр исходного кода

dpkg: Defer cleanup of .dpkg-new and .dpkg-tmp paths on removal

Clean them up only when we are definitely removing the main path.
Guillem Jover лет назад: 14
Родитель
Сommit
c1e19f3274
2 измененных файлов с 18 добавлено и 15 удалено
  1. 2 0
      debian/changelog
  2. 16 15
      src/remove.c

+ 2 - 0
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 <guillem@debian.org>  Fri, 03 Aug 2012 13:21:00 +0200
 

+ 16 - 15
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) {