]> code.citadel.org Git - citadel.git/blobdiff - citadel/messages.c
* Don't delete temp file when composing message until after server writes
[citadel.git] / citadel / messages.c
index 49ce8fd74c3e7f33d7e797c5b33bed737a2b24d5..f55946e7d21fa34abf130b57ef88aaba4428211f 100644 (file)
@@ -1195,13 +1195,11 @@ int entmsg(CtdlIPC *ipc,
        /* Reopen the temp file that was created, so we can send it */
        fp = fopen(temp, "r");
 
-       /* Yes, unlink it now, so it doesn't stick around if we crash */
-       unlink(temp);
-
        if (!fp || !(message.text = load_message_from_file(fp))) {
                err_printf("*** Internal error while trying to save message!\n"
                        "%s: %s\n",
                        temp, strerror(errno));
+               unlink(temp);
                return(errno);
        }
 
@@ -1214,6 +1212,9 @@ int entmsg(CtdlIPC *ipc,
                return (1);
        }
 
+       /* Yes, unlink it now, so it doesn't stick around if we crash */
+       unlink(temp);
+
        if (num_msgs >= 1) highmsg = msgarr[num_msgs - 1];
 
        if (msgarr) free(msgarr);