aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Warn if the temporary directory is not empty on cleanupNikolaus Schulz2010-07-191-2/+7
|
* When creating a dotlock, register it slightly earlier for cleanupNikolaus Schulz2010-07-191-1/+1
| | | | | This closes a very unlikely window where we could create a dotlock file, but then encounter an error and fail to clean up the dotlock.
* In verbose mode, say that we're about to dotlock an mbox before trying to do soNikolaus Schulz2010-07-191-1/+2
|
* Minor docstring/whitespace fixesNikolaus Schulz2010-07-191-3/+4
|
* At critical points, flush mbox files and sync them to diskNikolaus Schulz2010-07-191-3/+30
| | | | | | This should minimize the risk of data loss. Flushing a locked mbox file before unlocking it also ensures that there's no window when another process could lock the mbox after us, but still see the old content.
* Further refactoring of the mbox classes, adding archive locking supportNikolaus Schulz2010-07-191-46/+58
| | | | | | The mbox locking methods move into a new class LockableMboxMixin, and the Mbox and ArchiveMbox classes become subclasses of LockableMboxMixin. class StaleFiles is updated to handle multiple dotlock files.
* Fail as gracefully as possible if writing out the new mailboxes failsNikolaus Schulz2010-07-191-5/+35
| | | | | | | | | | In particular: * If writing the archived messages to the final archive fails, try to restore the archive and abort (by not handling the exception). This is possible since we first save the archive, and only then the modified mailbox, so we don't corrupt the original mbox in this case. * If writing a modified mbox file fails, save the temporary copy.
* Refactoring of the mbox classesNikolaus Schulz2010-07-191-133/+82
| | | | | | | | | | | | | | | | | | | | | | | The RetainMbox and ArchiveMbox classes are now gone, mainly because their finalise() methods were messing with the archived mbox and the archive, respectively, which was not good OO design. The core functionality of the finalise() methods of both removed classes is moved to the objects that are manipulated: the Mbox class representing the mbox that is being archived gains a new method overwrite_with(), and there is a new class ArchiveMbox that represents the actual archive, which has an append() method (yes, unfortunately the new class has the same name like the removed class). The RetainMbox instance is replaced with a TempMbox, and the ArchiveMbox instance either with a TempMbox, or a CompressedTempMbox if archive compression is enabled. Finally, a compressed TempMbox is now a implemented as a subclass of TempMbox, named CompressedMbox. Cooperation with the StaleFiles class moves into the TempMbox class. This means slightly less detailed verbose cleanup reporting, oh well.
* Use safe methods to open the archive mbox and an existing mbox fileNikolaus Schulz2010-07-191-8/+57
|
* mbox locking: omit dotlock if we don't have the permissions to create itNikolaus Schulz2010-07-192-2/+21
| | | | Closes: issue #855269.
* mbox locking: combine locking functions into one and swap lock orderNikolaus Schulz2010-07-192-39/+69
| | | | | | | | | | | | | We used to create a dotlock file first and then lock with fcntl; swap that order, since locking first with fcntl seems to be more common. This patch also adds general mbox lock/unlock methods, which call the dotlock and fcntl-lock methods, and moves the retry logic there. When the dotlock and fcntl methods fail to acquire a lock, they now raise a custom exception "LockUnavailable", which gets caught in the general lock() method. That way, if we succeed to acquire one lock but fail to acquire the other, we can release our locks at the upper level and retry.
* Switch mbox locking from flock(2) to posix lockf(2)Nikolaus Schulz2010-07-195-35/+24
| | | | flock() locks aren't portable; lockf() locks are.
* Rename procmail_lock->dotlock_lockNikolaus Schulz2010-07-192-23/+23
| | | | | An entirely cosmetic variable rename, but it's just not correct to call this a "procmail lock". Also reword some comments accordingly.
* test suite: use common base class with helper methods for mbox testingNikolaus Schulz2010-07-191-216/+168
| | | | | | | | These helper methods provide success verification after test archiving runs, and test case setup. This is a tradeoff: because these methods need to support all scenarios in one place, they introduce some new complexity - but they replace a lot of tedious, very similar, but still not entirely identical code all over the place.
* test suite: cut down the test of the --all optionNikolaus Schulz2010-07-191-19/+9
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: cut down the test of the --preserve-unread optionNikolaus Schulz2010-07-191-21/+8
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: change misleading test case nameNikolaus Schulz2010-07-191-3/+3
| | | | | | TestArchiveMboxPreserveStatus actually doesn't test that the message status is preserved, but that the --preserve-unread option works. Rename it to TestArchiveMboxPreserveUnread.
* test suite: cut down the test of the --size optionNikolaus Schulz2010-07-191-22/+9
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: cut down the test of --output-dirNikolaus Schulz2010-07-191-14/+5
| | | | | Don't do entire test archiving runs, just call archivemail.make_archive_name() and verify the result.
* test suite: cut down testing the handling of flagged messagesNikolaus Schulz2010-07-191-29/+10
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: remove duplicate test case for --date optionNikolaus Schulz2010-07-191-35/+0
|
* test suite: cut down archive suffix generation testingNikolaus Schulz2010-07-191-17/+8
| | | | | Don't do entire test archiving runs, just call archivemail.make_archive_name() and verify the result.
* test suite: test weird message headers in one runNikolaus Schulz2010-07-191-8/+12
| | | | Before, every test header was tested in a separate archiving run.
* test suite: cut down the test of date header processingNikolaus Schulz2010-07-191-15/+3
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: let make_message() optionally return a rfc822.MessageNikolaus Schulz2010-07-191-3/+7
|
* Remove lots of redundant test runs from the test suiteNikolaus Schulz2010-07-191-615/+347
| | | | | | | | | | | The test suite used to run a lot of triple tests, by first calling archivemail.archive() directly, and then running the entire archivemail script twice, once with long and once with short options. But we already test option processing seperately, and beyond that, archivemail.main() essentially just calls archive() for each mailbox in turn. So we just drop all runs of the entire archivemail script from the test suite, giving it a huge speed boost (on my old iBook, running the test suite drops from 73 to 5 seconds).
* Test suite: test command line option processingNikolaus Schulz2010-07-191-0/+88
|
* test suite: eliminate remaining call of external gzip programNikolaus Schulz2010-07-191-4/+6
| | | | Use gzip.GzipFile instead.
* test suite: define and use assertEqualContent() to compare filesNikolaus Schulz2010-07-191-114/+60
| | | | | This eliminates a lot of copy-and-paste code, and switches from os.system("gzip <...>") to gzip.GzipFile.
* test suite: account for lacking precision of os.utime()Nikolaus Schulz2010-07-191-6/+9
| | | | | | | os.utime() uses the utimes(2) system call to set file timestamps. utimes(2) has a microsecond resolution, but stat(2) may return timestamps with nanosecond resolution. So, the check that we have properly reset the mbox file timestamp must allow a minor deviation.
* Fix minor race when deleting messages in a maildir/mh boxNikolaus Schulz2010-07-191-3/+4
| | | | | Nothing serious, but if another client deleted it in the small window after we checked it, we would have crashed trying to delete a non-existing file.
* Simplify the final committing of the mailbox and archiveNikolaus Schulz2010-07-192-83/+54
| | | | | | | | | | * Make the finalise() methods spot if they have anything to do * We used to create the temporary mbox files on demand in the message processing loop, if we needed to write to them. Now we create them beforehand, but only if they might be needed (e.g. we don't create an archive if options.delete_old_mail is set). * The above combined makes the final committing of the changes simpler (a *lot* simpler for mboxes), and we can dump the Mbox.leave_empty() method.
* Split out new class TempMboxNikolaus Schulz2010-07-192-111/+121
| | | | | This separates write-only mbox access to the temporary mboxes from the read-only access to the original mbox.
* Simplify ArchiveMbox.__init__Nikolaus Schulz2009-11-061-15/+5
|
* Append to the archive, and don't use rename()Nikolaus Schulz2009-11-061-40/+20
| | | | | This is WIP to prepare locking for the archive. Since we no longer copy the whole archive before appending, archiving should also be faster.
* Remove unused method Mbox.is_empty()Nikolaus Schulz2009-11-062-20/+0
|
* Keep mbox files open, so we don't break our locksNikolaus Schulz2009-11-061-34/+17
| | | | | | When committing a changed mbox, don't use os.rename(), and don't open/close the mbox file to truncate it to zero length. Locking was pretty much broken before -- at least in theory a quite severe bug.
* Cleanup restoring of the mbox timestampsNikolaus Schulz2009-11-061-14/+5
| | | | | | | | * Remove code duplication: restore the mbox timestamps once and for all when we're done * Don't bother restoring the file mode when finishing, since this is handled in RetainMbox.finalise() (and need be) * Therefore, rename Mbox.reset_stat() to reset_timestamps()
* Cosmetics: in verbose mode, report current mailbox earlyNikolaus Schulz2009-11-061-1/+1
| | | | | This is now before we do the sanity checking, so in verbose mode, we don't error out before having said that we now turn attention to the current mailbox.
* Refuse to process mailboxes owned by someone elseNikolaus Schulz2009-11-061-2/+12
| | | | | | This should also protect people relying on the old setuid feature. If the mailbox is local, by checking the ownership we necessarily check for existance.
* Sanity check existing archives earlyNikolaus Schulz2009-11-061-10/+15
| | | | | This used to happen when creating the temporary archive, we now do it before we start processing the mailbox.
* Remove simple-minded security checksNikolaus Schulz2009-11-061-12/+0
| | | | | Remove the checks if the mailbox is a symlink, and if the output directory is world-writable. Better no security than half-baked security.
* Move archive naming code into new function make_archive_name()Nikolaus Schulz2009-11-061-18/+21
|
* Remove the setuid functionalityNikolaus Schulz2009-11-061-24/+0
| | | | It was not a good idea, and trying to do it right would be too much effort.
* Simplify imap_get_namespace() and imap_guess_mailboxnames()Nikolaus Schulz2009-11-061-15/+15
| | | | | | I don't think anybody wants to archive folders in shared or public IMAP namespaces, so we don't bother checking all possible namespaces. The code was ugly anyway.
* Removed obsolete references to subversionNikolaus Schulz2009-11-063-19/+9
| | | | | | archivemail development has moved to git. This patch updates the project webpage, removes the subversion $Id$ keyword that was stored in archivemail.__svn_id__, and updates the Makefile.
* IMAP: imap_guess_mailboxnames: check for NIL delimiter. Nikolaus Schulz2008-04-091-1/+1
| | | | | | Only replace the slash with the server's hierarchy delimiter if the latter actually exists (is not NIL).
* TODO: dropped items about --all, which is now implemented.Nikolaus Schulz2008-04-081-4/+2
|
* IMAP: only check for \Deleted in PERMANENTFLAGS if mailbox isn't read-only.Nikolaus Schulz2008-04-081-1/+1
| | | | | This spewed an error when --dry-running.
* IMAP: added sanity check for \Deleted in PERMANENTFLAGS.Nikolaus Schulz2008-04-081-0/+14
|