micronode / mstor

Messaging store and archival tool
https://www.mstor.org
Other
11 stars 2 forks source link

Unable to rename file on different mount point #10

Open sekkuar opened 7 years ago

sekkuar commented 7 years ago

When mailbox file cannot be moved to the /tmp/ directory, saving the mailbox file fails

>mv /var/spool/mail/sardev /tmp/sardevmail
mv: 0653-404 /tmp/sardevmail: Unable to duplicate owner and mode after move.
mv: 0653-406 Cannot remove source file /var/spool/mail/sardev
javax.mail.MessagingException: Error purging mbox file;
  nested exception is:
    java.io.IOException: Unable to rename existing file
    at net.fortuna.mstor.connector.mbox.MboxFolder.expunge(MboxFolder.java:373)

As discussed on the forums https://sourceforge.net/p/mstor/discussion/390660/thread/662967b0/

benfortuna commented 7 years ago

After looking at the code I realised you can probably fix this by overriding the java.io.tmpdir system property:

    File newFile = new File(System.getProperty("java.io.tmpdir"),
    file.getName() + TEMP_FILE_EXTENSION);

Try setting this property to a directory on the same mount point as the original mbox file. If you can't override this system property we can probably support a specific temp directory just for mstor.

sekkuar commented 7 years ago

Well, I'm not longer part of that project, and the official solution was to make our own build removing the exception throwing.

However, I do believe it is a good thing to have the API work regardless of system properties, as other parts of the application may rely on it.