mirror of
https://git.code.sf.net/p/archivemail/code
synced 2024-12-22 07:42:55 +00:00
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.
This commit is contained in:
parent
71485f2469
commit
eadedf27d0
1 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue