ソースを参照

dpkg-divert: Remove temporary file on error during --rename

Do not leave the «.dpkg-divert.tmp» temporary file around if the file
copy failed for any reason.
Guillem Jover 14 年 前
コミット
66940305bb
共有2 個のファイルを変更した4 個の追加1 個の削除を含む
  1. 1 0
      debian/changelog
  2. 3 1
      src/divertcmd.c

+ 1 - 0
debian/changelog

@@ -129,6 +129,7 @@ dpkg (1.17.0) UNRELEASED; urgency=low
     strategies are: filtered, huffman, rle and fixed.
   * Change dpkg and dpkg-deb help output to recommend apt instead of dselect
     as a user-friendly frontend.
+  * Remove temporary file on error during «dpkg-divert --rename».
 
   [ Updated programs translations ]
   * Fix typo in Spanish translation of update-alternatives.

+ 3 - 1
src/divertcmd.c

@@ -221,7 +221,7 @@ file_copy(const char *src, const char *realdst)
 	if (dstfd < 0)
 		ohshite(_("unable to create file '%s'"), dst);
 
-	/* FIXME: leaves a dangling destination file on error. */
+	push_cleanup(cu_filename, ~ehflag_normaltidy, NULL, 0, 1, dst);
 
 	if (fd_fd_copy(srcfd, dstfd, -1, &err) < 0)
 		ohshit(_("cannot copy '%s' to '%s': %s"), src, dst, err.str);
@@ -239,6 +239,8 @@ file_copy(const char *src, const char *realdst)
 		ohshite(_("cannot rename '%s' to '%s'"), dst, realdst);
 
 	free(dst);
+
+	pop_cleanup(ehflag_normaltidy);
 }
 
 static void