[issue15122] Add an option to always rewrite single-file mailboxes in-place.

Petri Lehtinen report at bugs.python.org
Thu Jun 21 20:31:29 CEST 2012


Petri Lehtinen <petri at digip.org> added the comment:

I looked at the source code of mutt to see how it rewrites mbox files. It does roughly this:

1. Block some signals.

2. Lock the mbox file (with dotlock, fcntl and flock).

3. Create a temporary file in /tmp.

4. Write messages to the temporary file, from the point where the first change is up to the end of the mbox file. This saves a lot of writing when the first change is near the end of the file.

5. Write changes from the temporary file to the mbox file, modifying the mbox file in-place.

6. Truncate the mbox file to the correct length.

7. Unblock signals.

If writing the changes back to the mbox file fails, the temporary file is copied from /tmp to near the mbox file.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15122>
_______________________________________


More information about the Python-bugs-list mailing list