aboutsummaryrefslogtreecommitdiffstats
path: root/archivemail.py
diff options
context:
space:
mode:
authorPaul Rodger <paul@paulrodger.com>2002-05-06 03:06:40 +0000
committerPaul Rodger <paul@paulrodger.com>2002-05-06 03:06:40 +0000
commite4adb7b2228533cde7936b44b5d61e422c81bb6b (patch)
treee16ff77acbd4dfd875d605901cf1162a4eecf8b1 /archivemail.py
parent7187dd8f6fc3c798958d3fbbaa842edc8276c873 (diff)
downloadarchivemail-e4adb7b2228533cde7936b44b5d61e422c81bb6b.tar.gz
archivemail-e4adb7b2228533cde7936b44b5d61e422c81bb6b.tar.bz2
archivemail-e4adb7b2228533cde7936b44b5d61e422c81bb6b.zip
Fixed a bug where the os.rename() calls could fail if we are moving files
between partitions.
Diffstat (limited to 'archivemail.py')
-rwxr-xr-xarchivemail.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/archivemail.py b/archivemail.py
index 182d43a..8020e89 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -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