summaryrefslogtreecommitdiffstats
path: root/bcache.c
diff options
context:
space:
mode:
authorBrendan Cully <brendan@kublai.com>2009-01-26 12:32:30 -0800
committerBrendan Cully <brendan@kublai.com>2009-01-26 12:32:30 -0800
commitcdd1d9279e447e668fb037ef3d14162ea461cf32 (patch)
tree06867940b2ed42f475ad5c6937af2de8d77b62c3 /bcache.c
parentaa980ced0930947a0388d655ebe9fab1aabcf7bb (diff)
Remove old bcache tmpfile before trying to create new one. Closes #3163.
Diffstat (limited to 'bcache.c')
-rw-r--r--bcache.c8
1 files changed, 8 insertions, 0 deletions
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;