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;