The following commit has been merged in the master branch:
commit 66940305bb7afc59b8be55f5afc6def1fb335efe
Author: Guillem Jover <[email protected]>
Date:   Wed Jul 4 11:37:51 2012 +0200

    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.

diff --git a/debian/changelog b/debian/changelog
index 3c888a2..710fc97 100644
--- a/debian/changelog
+++ b/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.
diff --git a/src/divertcmd.c b/src/divertcmd.c
index 4f390fe..55817eb 100644
--- a/src/divertcmd.c
+++ b/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

-- 
dpkg's main repository


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

Reply via email to