X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/19304f7c526fbe36ba0db2fb80bcaf3bd974d81d..03799e24b23b9a04aee38d40898625a71b92b5e6:/bcache.c?ds=sidebyside 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;