X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/19304f7c526fbe36ba0db2fb80bcaf3bd974d81d..fc83c7648c73765a72c74175b6952a0fda80dd00:/bcache.c diff --git a/bcache.c b/bcache.c index 60e5fdc..81538d2 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;