Check if path exists before trying to create it.

see #482
This commit is contained in:
Antoine Nguyen
2013-09-14 17:05:35 +02:00
parent 71856df2da
commit f2f4e243ae
2 changed files with 8 additions and 7 deletions
@@ -25,10 +25,11 @@ class Command(BaseCommand):
if not os.path.exists(operation.argument):
return
new_mail_home = operation.mailbox.mail_home
try:
os.makedirs(os.path.dirname(new_mail_home))
except os.error as e:
raise OperationError(str(e))
if not os.path.exists(new_mail_home):
try:
os.makedirs(os.path.dirname(new_mail_home))
except os.error as e:
raise OperationError(str(e))
code, output = exec_cmd(
"mv %s %s" % (ope.argument, new_mail_home)
)
@@ -56,7 +57,7 @@ class Command(BaseCommand):
try:
f(ope)
except (OperationError, AdminError) as e:
self.logger.critical('Operation failed: %s. Reason: %s', ope, str(e))
self.logger.critical('%s failed (reason: %s)', ope, e)
else:
self.logger.info('Operation succeed: %s', ope)
self.logger.info('%s succeed', ope)
ope.delete()
+1 -1
View File
@@ -1028,7 +1028,7 @@ class MailboxOperation(models.Model):
def __str__(self):
if self.type == 'rename':
return 'Rename %s -> %s' % (self.argument, self.mailbox.full_address)
return 'Rename %s -> %s' % (self.argument, self.mailbox.mail_home)
return 'Delete %s' % self.argument