Index: imap/sync_support.c =================================================================== RCS file: /cvs/src/cyrus/imap/sync_support.c,v retrieving revision 1.18 diff -u -d -r1.18 sync_support.c --- imap/sync_support.c 24 Mar 2008 17:09:20 -0000 1.18 +++ imap/sync_support.c 25 Mar 2008 13:00:34 -0000 @@ -1365,6 +1365,15 @@ if ((r = sync_getliteral_size(input, output, &message->msg_size))) return(r); + /* unlink just in case a previous crash left a file + * hard linked into someone else's mailbox! */ + if (unlink(message->msg_path) == -1 && errno != ENOENT) { + syslog(LOG_ERR, + "sync_getsimple(): failed to unlink stale file %s: %m", + message->msg_path); + return(IMAP_IOERROR); + } + /* Open read/write so file can later be mmap()ed */ if ((file=fopen(message->msg_path, "w+")) == NULL) { syslog(LOG_ERR, "sync_getsimple(): Unable to open %s: %m",