Explorar o código

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

Otherwise we might leave cruft behind.

Regression introduced in commit 02b12d75f1eff7c184fafb5a663a0421e9a645ea.
Guillem Jover %!s(int64=15) %!d(string=hai) anos
pai
achega
922093b5fb
Modificáronse 2 ficheiros con 6 adicións e 0 borrados
  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
     up the error codes, this improves error reporting and avoids triggering
     leak detectors. Closes: #620380
+  * When moving a diverted file across filesystems in dpkg-divert, remove
+    the source file.
 
   [ Raphaël Hertzog ]
   * 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. */
 		file_copy(src->name, dst->name);
+
+		if (unlink(src->name))
+			ohshite(_("unable to remove copied source file '%s'"),
+			        src->name);
 	}
 }