Fixed a bug where the os.rename() calls could fail if we are moving files

between partitions.
This commit is contained in:
Paul Rodger 2002-05-06 03:06:40 +00:00
parent 7187dd8f6f
commit e4adb7b222
5 changed files with 20 additions and 7 deletions

View File

@ -1,4 +1,8 @@
Version 0.4.6 - 6 May 2002
* Fixed a bug where the os.rename() calls could fail if we were moving
temporary files across different filesystems/partitions.
Version 0.4.5 - 29 April 2002
* Fixed a bug where if you used the '--delete' option to completely clean
an mbox mailbox you would get a python error.

View File

@ -1,5 +1,5 @@
VERSION=0.4.5
VERSION=0.4.6
VERSION_TAG=v$(subst .,_,$(VERSION))
TARFILE=archivemail-$(VERSION).tar.gz

2
TODO
View File

@ -1,5 +1,5 @@
Goals for next minor release (0.4.6):
Goals for next minor release (0.4.7):
-------------------------------------
* Think about the best way to specify the names of archives created with
possibly an --archive-name option.

View File

@ -22,7 +22,7 @@ Website: http://archivemail.sourceforge.net/
"""
# global administrivia
__version__ = "archivemail v0.4.5"
__version__ = "archivemail v0.4.6"
__cvs_id__ = "$Id$"
__copyright__ = """Copyright (C) 2002 Paul Rodger <paul@paulrodger.com>
This is free software; see the source for copying conditions. There is NO
@ -392,7 +392,6 @@ class Mbox(mailbox.UnixMailbox):
completely deleted."""
assert(os.path.isfile(self.mbox_file_name))
vprint("turning '%s' into a zero-length file" % self.mbox_file_name)
mtime = os.path.getmtime(self.mbox_file_name)
blank_file = open(self.mbox_file_name, "w")
blank_file.close()
@ -439,7 +438,12 @@ class RetainMbox(Mbox):
os.chmod(self.mbox_file_name, mode)
vprint("renaming '%s' to '%s'" % (self.mbox_file_name, self.__final_name))
os.rename(self.mbox_file_name, self.__final_name)
try:
os.rename(self.mbox_file_name, self.__final_name)
except OSError:
# file might be on a different filesystem -- move it manually
shutil.copy2(self.mbox_file_name, self.__final_name)
os.remove(self.mbox_file_name)
os.utime(self.__final_name, (atime, mtime)) # reset to original timestamps
_stale.retain = None
@ -525,7 +529,12 @@ manually, and try running me again.""" % final_name)
final_name = final_name + ".gz"
vprint("renaming '%s' to '%s'" % (self.mbox_file_name,
final_name))
os.rename(self.mbox_file_name, final_name)
try:
os.rename(self.mbox_file_name, final_name)
except OSError:
# file might be on a different filesystem -- move it manually
shutil.copy2(self.mbox_file_name, final_name)
os.remove(self.mbox_file_name)
_stale.archive = None

View File

@ -19,7 +19,7 @@ check_python_version() # define & run this early - 'distutils.core' is new
from distutils.core import setup
setup(name="archivemail",
version="0.4.5",
version="0.4.6",
description="archive and compress old email",
license="GNU GPL",
url="http://archivemail.sourceforge.net/",