aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
|
* Minor, local variable renaming.Nikolaus Schulz2008-04-081-6/+6
|
* Moved IMAP SELECT code into a separate function.Nikolaus Schulz2008-04-081-15/+20
|
* IMAP: be NAMESPACE-aware; improved probing for guessed mailbox names. Nikolaus Schulz2008-04-084-30/+86
| | | | | | | | * Automatically add NAMESPACE prefix to the mailbox path if necessary, * Explicitely check for guessed mailbox names with LIST instead of just trying to SELECT them. * Updated documentation about NAMESPACE handling.
* archivemail.sgml: warn that multiple passes with --copy will create duplicates. Nikolaus Schulz2008-04-082-1/+5
|
* Code structuring: made a separate group of IMAP functions. Nikolaus Schulz2008-04-071-58/+65
| | | | | No code changes, just moved functions around.
* IMAP: servers should never advertise LOGINDISABLED with SSL; removed the checkNikolaus Schulz2008-03-211-5/+1
| | | | | for it, which was just used to spit a special error message anyway.
* Archiving an IMAP folder with --all didn't archive *any* messages.Nikolaus Schulz2008-03-191-1/+1
| | | | | | The message sequence numbers must be strings, but were generated as integers; fixed.