aboutsummaryrefslogtreecommitdiffstats
path: root/archivemail.py
Commit message (Collapse)AuthorAgeFilesLines
* Updated copyright yearNikolaus Schulz2010-07-291-2/+2
|
* Fix TempMbox.saveas() to unregister the right file from _staleNikolaus Schulz2010-07-281-1/+1
|
* Python language fix: replace C-style boolean values "1" and "0" with True/FalseNikolaus Schulz2010-07-191-48/+48
|
* Remove unused variableNikolaus Schulz2010-07-191-1/+0
|
* Python language fix: remove parentheses around asserted expressionsNikolaus Schulz2010-07-191-39/+39
| | | | assert is not a function.
* Add a note about the race window when resetting an mbox file timestampNikolaus Schulz2010-07-191-1/+1
|
* 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-191-2/+10
| | | | Closes: issue #855269.
* mbox locking: combine locking functions into one and swap lock orderNikolaus Schulz2010-07-191-35/+65
| | | | | | | | | | | | | 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-191-9/+9
| | | | flock() locks aren't portable; lockf() locks are.
* Rename procmail_lock->dotlock_lockNikolaus Schulz2010-07-191-16/+16
| | | | | An entirely cosmetic variable rename, but it's just not correct to call this a "procmail lock". Also reword some comments accordingly.
* 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-191-68/+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-191-85/+94
| | | | | 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-061-4/+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-061-1/+0
| | | | | | 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).
* 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-081-17/+74
| | | | | | | | * 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.
* 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.
* Updated year in another copyright note, which I overlooked before.Nikolaus Schulz2008-03-161-1/+1
|
* Removed an assertion which choked upon --days=0. Nikolaus Schulz2008-03-151-3/+0
|
* Added new option --all to archive all messages in a mailbox.Nikolaus Schulz2008-03-151-11/+20
| | | | | | Updated documentation, and added a first simple unittest for this. Closes: #1764846.
* Updated copyright notes to include year 2008.Nikolaus Schulz2008-03-151-1/+1
|
* Fixed crash when archiving an empty maildir with python 2.5. Nikolaus Schulz2008-03-151-1/+0
| | | | | | The incompatible changes in mailbox.Maildir triggered an assertion in _archive_dir(); removing that assertion since it looks not useful anyway.
* Sanitized parsing some IMAP server responses by switching to regularNikolaus Schulz2008-03-151-8/+8
| | | | | expressions.