Create exception when file rename fails

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Vladimir Marek 2011-08-17 10:01:39 +02:00 committed by Nicolas Sebrecht
parent 466ded04d9
commit df62bb61a5

View File

@ -299,8 +299,14 @@ class MaildirFolder(BaseFolder):
newfilename = os.path.join(dir_prefix, newname)
if (newfilename != oldfilename):
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