From eadedf27d09776b2ad59364a86fa1af6cbe86525 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Fri, 30 Jul 2010 13:24:36 +0200 Subject: Fix crash when unlocking an mbox after dotlocking failed with EACCES If we don't have sufficient permissions to create a dotlock for an mbox file, record that, and don't try to remove the dotlock when unlocking the mbox later. --- archivemail | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'archivemail') diff --git a/archivemail b/archivemail index be90413..ec05171 100755 --- a/archivemail +++ b/archivemail @@ -323,6 +323,7 @@ class LockableMboxMixin: self.mbox_file = mbox_file self.mbox_file_name = mbox_file_name self._locked = False + self._use_dotlock = True def lock(self): """Lock this mbox with both a dotlock and a posix lock.""" @@ -386,6 +387,7 @@ class LockableMboxMixin: if not options.quiet: user_warning("no write permissions: omitting dotlock for '%s'" % \ self.mbox_file_name) + self._use_dotlock = False return raise try: @@ -411,7 +413,8 @@ class LockableMboxMixin: def _dotlock_unlock(self): """Delete the dotlock file for the 'mbox' mailbox.""" - assert self.mbox_file_name + if not self._use_dotlock: + return lock_name = self.mbox_file_name + options.lockfile_extension vprint("removing lockfile '%s'" % lock_name) os.remove(lock_name) -- cgit v1.2.3