From cdd1d9279e447e668fb037ef3d14162ea461cf32 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Mon, 26 Jan 2009 12:32:30 -0800 Subject: [PATCH] Remove old bcache tmpfile before trying to create new one. Closes #3163. --- ChangeLog | 8 ++++++++ bcache.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4ef5bbd3..bb842e88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-01-20 12:34 -0800 René Clerc (2006526d1d26) + + * po/nl.po: Updated Dutch translation + +2009-01-19 20:39 -0800 Ivan Vilata i Balaguer (038f1e5cdaea) + + * po/ca.po: Updated Catalan translation + 2009-01-14 20:04 +0000 Emanuele Giaquinta (ddf48761aacf) * imap/browse.c: Use imap_utf7_encode instead of diff --git a/bcache.c b/bcache.c index 60e5fdca..81538d22 100644 --- a/bcache.c +++ b/bcache.c @@ -136,6 +136,13 @@ FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp) snprintf (path, sizeof (path), "%s%s%s", bcache->path, id, tmp ? ".tmp" : ""); + if ((fp = safe_fopen (path, "w+"))) + goto out; + + if (errno == EEXIST) + /* clean up leftover tmp file */ + mutt_unlink (path); + s = strchr (path + 1, '/'); while (!(fp = safe_fopen (path, "w+")) && errno == ENOENT && s) { @@ -147,6 +154,7 @@ FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp) s = strchr (s + 1, '/'); } + out: dprint (3, (debugfile, "bcache: put: '%s'\n", path)); return fp; -- 2.40.0