/*
- * Copyright (C) 2006 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 2006-7 Brendan Cully <brendan@kublai.com>
* Copyright (C) 2006 Rocco Rutte <pdmef@gmx.net>
*
* This program is free software; you can redistribute it and/or modify
{
char host[STRING];
ciss_url_t url;
- size_t len;
+ int len;
if (!account || !MessageCachedir || !*MessageCachedir || !dst || !dstlen)
return -1;
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)
{
s = strchr (s + 1, '/');
}
+ out:
dprint (3, (debugfile, "bcache: put: '%s'\n", path));
return fp;