X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..1bab28984d8d360498fe316bf13187c907273b47:/bcache.c diff --git a/bcache.c b/bcache.c index ac07849..81538d2 100644 --- a/bcache.c +++ b/bcache.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Brendan Cully + * Copyright (C) 2006-7 Brendan Cully * Copyright (C) 2006 Rocco Rutte * * This program is free software; you can redistribute it and/or modify @@ -43,7 +43,7 @@ static int bcache_path(ACCOUNT *account, const char *mailbox, { char host[STRING]; ciss_url_t url; - size_t len; + int len; if (!account || !MessageCachedir || !*MessageCachedir || !dst || !dstlen) return -1; @@ -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;