[PATCH 3/3] Create exception when file rename fails
Vladimir.Marek at oracle.com
Vladimir.Marek at oracle.com
Wed Aug 17 09:01:39 BST 2011
From: Vladimir Marek <vlmarek at volny.cz>
Signed-off-by: Vladimir Marek <vlmarek at volny.cz>
---
offlineimap/folder/Maildir.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index 2646205..731cc08 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -294,8 +294,14 @@ class MaildirFolder(BaseFolder):
newfilename = os.path.join(dir_prefix, newname)
if (newfilename != oldfilename):
- os.rename(os.path.join(self.getfullname(), oldfilename),
- os.path.join(self.getfullname(), newfilename))
+ try:
+ os.rename(os.path.join(self.getfullname(), oldfilename),
+ os.path.join(self.getfullname(), newfilename))
+ except OSError, e:
+ raise OfflineImapError("Can't rename file '%s' to '%s': %s" % (
+ oldfilename, newfilename, e[1]),
+ OfflineImapError.ERROR.FOLDER)
+
self.messagelist[uid]['flags'] = flags
self.messagelist[uid]['filename'] = newfilename
--
Vlad
More information about the OfflineIMAP-project
mailing list