浏览代码

dpkg-divert: Unlink the source file when moving across filesystems

Otherwise we might leave cruft behind.

Regression introduced in commit 02b12d75f1eff7c184fafb5a663a0421e9a645ea.
Guillem Jover 15 年之前
父节点
当前提交
922093b5fb
共有 2 个文件被更改,包括 6 次插入 和 0 次删除
  1. 2 0
      debian/changelog
  2. 4 0
      src/divertcmd.c

+ 2 - 0
debian/changelog

@@ -53,6 +53,8 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   * Terminate immediately on dpkg-divert rename errors instead of propagating
   * Terminate immediately on dpkg-divert rename errors instead of propagating
     up the error codes, this improves error reporting and avoids triggering
     up the error codes, this improves error reporting and avoids triggering
     leak detectors. Closes: #620380
     leak detectors. Closes: #620380
+  * When moving a diverted file across filesystems in dpkg-divert, remove
+    the source file.
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854
   * Fail properly when debian/source/format is empty. Closes: #600854

+ 4 - 0
src/divertcmd.c

@@ -256,6 +256,10 @@ file_rename(struct file *src, struct file *dst)
 
 
 		/* If a rename didn't work try moving the file instead. */
 		/* If a rename didn't work try moving the file instead. */
 		file_copy(src->name, dst->name);
 		file_copy(src->name, dst->name);
+
+		if (unlink(src->name))
+			ohshite(_("unable to remove copied source file '%s'"),
+			        src->name);
 	}
 	}
 }
 }