restore-mail-inject.py - Tool to inject mails via IMAP
Copyright (c) 2012 Intra2net AG
+Author: Plamen Dimitrov and Thomas Jarosch
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
'''
import os
try:
with open(mboxlistfile, 'r') as acl_file:
for line in acl_file:
+
acls = {}
try:
linedata = MBOXFILE_LINE.match(line).groups()
return
# mark mailboxes that should be created
self.created_mailboxes.append(mailpath)
+
subpaths = os.listdir(filepath)
for subpath in subpaths:
if subpath == "." or subpath == "..":
continue
new_filepath = filepath + "/" + subpath
+
+ # if path is file validate name and inject
if (os.path.isfile(new_filepath)):
if os.path.getsize(new_filepath) == 0:
logging.info("Skipping empty file %s", subpath)
except IOError:
logging.warning("Could not retrieve mail from the file %s", new_filepath)
else:
+
+ # if path is directory do recursive call
if os.path.isdir(new_filepath):
# cyrus ^ vs . storage replacement
subpath = subpath.replace("^", ".")
for rcr in rcrs_generator:
yield rcr
logging.debug("Done with directory %s and mailbox %s", new_filepath, new_mailpath)
+
# mark mailboxes that need acl update
self.acl_mailboxes.append(mailpath)