summaryrefslogtreecommitdiffstats
path: root/pykolab/imap
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-11-21 13:54:24 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-11-21 13:54:24 +0100
commit66b6626f4cbf07a0ca7ff58fa5ed7f209094107e (patch)
tree1deef7d87f23266126f5d6612ddeb39bd0788147 /pykolab/imap
parent7e1324dad409e2f9319c3347f071364f0c8f12aa (diff)
downloadpykolab-66b6626f4cbf07a0ca7ff58fa5ed7f209094107e.tar.gz
Only create the INBOX folder and apply the rest of the logic when the INBOX folder does not already exist
Diffstat (limited to 'pykolab/imap')
-rw-r--r--pykolab/imap/__init__.py72
1 files changed, 40 insertions, 32 deletions
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 0cd89fc..6c8be22 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -174,43 +174,43 @@ class IMAP(object):
for folder in inbox_folders:
additional_folders = None
- try:
- if folders.index(folder) > -1:
- continue
- else:
- # TODO: Perhaps this block is moot
- log.info(_("Creating new INBOX for user (%d): %s")
- %(1,folder))
- try:
- self.imap.cm("user/%s" %(folder))
- except:
- log.warning(_("Mailbox already exists: user/%s")
- %(folder))
- continue
- if conf.get('kolab', 'imap_backend') == 'cyrus-imap':
- self.imap._setquota("user/%s" %(folder),0)
-
- except:
+ if not self.has_folder("user%s%s" %(self.imap.separator, folder)):
# TODO: Perhaps this block is moot
- log.info(_("Creating new INBOX for user (%d): %s") %(2,folder))
+ log.info(_("Creating new INBOX for user (%d): %s")
+ %(1,folder))
try:
- self.imap.cm("user/%s" %(folder))
+ self.imap.cm("user%s%s" %(self.imap.separator, folder))
except:
- log.warning(_("Mailbox already exists: user/%s") %(folder))
+ log.warning(
+ _("Mailbox already exists: user%s%s") %(
+ self.imap.separator,folder
+ )
+ )
+
continue
- self.imap._setquota("user/%s" %(folder),0)
-
- if conf.has_option(domain_section, "autocreate_folders"):
- _additional_folders = conf.get_raw(domain_section, "autocreate_folders")
- additional_folders = conf.plugins.exec_hook("create_user_folders",
- kw={
- 'folder': folder,
- 'additional_folders': _additional_folders
- }
- )
- if not additional_folders == None:
- self.create_user_additional_folders(folder, additional_folders)
+ if conf.get('kolab', 'imap_backend') == 'cyrus-imap':
+ self.imap._setquota(
+ "user%s%s" %(self.imap.separator, folder),
+ 0
+ )
+
+ if conf.has_option(domain_section, "autocreate_folders"):
+ _additional_folders = conf.get_raw(
+ domain_section,
+ "autocreate_folders"
+ )
+
+ additional_folders = conf.plugins.exec_hook(
+ "create_user_folders",
+ kw={
+ 'folder': folder,
+ 'additional_folders': _additional_folders
+ }
+ )
+
+ if not additional_folders == None:
+ self.create_user_additional_folders(folder, additional_folders)
return inbox_folders
@@ -247,6 +247,12 @@ class IMAP(object):
"%s" %(additional_folders[additional_folder]["annotations"][annotation])
)
+ if additional_folders[additional_folder].has_key("quota"):
+ self.imap.sq(
+ folder_name,
+ additional_folders[additional_folder]['quota']
+ )
+
if additional_folders[additional_folder].has_key("acls"):
for acl in additional_folders[additional_folder]["acls"].keys():
self.imap.sam(
@@ -444,6 +450,8 @@ class IMAP(object):
log.error(_("Please don't give us just a user identifier"))
return
+ log.info(_("Deleting folder %s") %(mailfolder_path))
+
self.imap.dm(mailfolder_path)
clean_acls = False