1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-23 08:14:58 +00:00

Fixed a bug where if you use the '--delete' option to completely clean

an mbox mailbox you would get a python error.
This commit is contained in:
Paul Rodger 2002-04-28 04:00:11 +00:00
parent bc41b68389
commit 15be93bd0d

View file

@ -223,10 +223,12 @@ class Options:
if is_world_writable(self.output_dir): if is_world_writable(self.output_dir):
unexpected_error(("output directory is world-writable: " + \ unexpected_error(("output directory is world-writable: " + \
"%s -- I feel nervous!") % self.output_dir) "%s -- I feel nervous!") % self.output_dir)
if (self.days_old_max < 1): if self.days_old_max < 1:
user_error("argument to -d must be greater than zero") user_error("argument to -d must be greater than zero")
if (self.days_old_max >= 10000): if self.days_old_max >= 10000:
user_error("argument to -d must be less than 10000") user_error("argument to -d must be less than 10000")
if self.quiet and self.verbose:
user_error("you cannot use both the --quiet and --verbose options")
def date_argument(self, string): def date_argument(self, string):
"""Converts a date argument string into seconds since the epoch""" """Converts a date argument string into seconds since the epoch"""
@ -868,6 +870,7 @@ def archive(mailbox_name):
os.path.basename(final_archive_name)) os.path.basename(final_archive_name))
vprint("archiving '%s' to '%s' ..." % (mailbox_name, final_archive_name)) vprint("archiving '%s' to '%s' ..." % (mailbox_name, final_archive_name))
old_temp_dir = tempfile.tempdir
tempfile.tempdir = choose_temp_dir(mailbox_name) tempfile.tempdir = choose_temp_dir(mailbox_name)
assert(tempfile.tempdir) assert(tempfile.tempdir)
vprint("set tempfile directory to '%s'" % tempfile.tempdir) vprint("set tempfile directory to '%s'" % tempfile.tempdir)
@ -905,6 +908,7 @@ def archive(mailbox_name):
vprint("changing effective groupid and userid back to root") vprint("changing effective groupid and userid back to root")
os.setegid(0) os.setegid(0)
os.seteuid(0) os.seteuid(0)
tempfile.tempdir = old_temp_dir
def _archive_mbox(mailbox_name, final_archive_name): def _archive_mbox(mailbox_name, final_archive_name):
@ -965,7 +969,7 @@ def _archive_mbox(mailbox_name, final_archive_name):
if options.delete_old_mail: if options.delete_old_mail:
# we will never have an archive file # we will never have an archive file
if retain: if retain:
retain.finalise(mailbox_name) retain.finalise()
else: else:
# nothing was retained - everything was deleted # nothing was retained - everything was deleted
original.leave_empty() original.leave_empty()