diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py index e855210..606294e 100644 --- a/offlineimap/repository/Base.py +++ b/offlineimap/repository/Base.py @@ -124,6 +124,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin, object): raise NotImplementedError def makefolder(self, foldername): + """Create a new folder""" raise NotImplementedError def deletefolder(self, foldername): diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 1b13d79..28e73b7 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -341,11 +341,11 @@ class IMAPRepository(BaseRepository): foldername = self.getreference() + self.getsep() + foldername if not foldername: # Create top level folder as folder separator foldername = self.getsep() - + self.ui.makefolder(self, foldername) + if self.account.dryrun: + return imapobj = self.imapserver.acquireconnection() try: - self.ui._msg("Creating new IMAP folder '%s' on server %s" %\ - (foldername, self)) result = imapobj.create(foldername) if result[0] != 'OK': raise OfflineImapError("Folder '%s'[%s] could not be created. " diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py index 30c8560..3e5db2f 100644 --- a/offlineimap/repository/LocalStatus.py +++ b/offlineimap/repository/LocalStatus.py @@ -67,10 +67,11 @@ class LocalStatusRepository(BaseRepository): Empty Folder for plain backend. NoOp for sqlite backend as those are created on demand.""" - # Invalidate the cache. - self._folders = None if self._backend == 'sqlite': - return + return # noop for sqlite which creates on-demand + + if self.account.dryrun: + return # bail out in dry-run mode filename = self.getfolderfilename(foldername) file = open(filename + ".tmp", "wt") diff --git a/offlineimap/repository/Maildir.py b/offlineimap/repository/Maildir.py index 7c08d64..f197002 100644 --- a/offlineimap/repository/Maildir.py +++ b/offlineimap/repository/Maildir.py @@ -81,7 +81,9 @@ class MaildirRepository(BaseRepository): levels will be created if they do not exist yet. 'cur', 'tmp', and 'new' subfolders will be created in the maildir. """ - self.debug("makefolder called with arg '%s'" % (foldername)) + self.ui.makefolder(self, foldername) + if self.account.dryrun: + return full_path = os.path.abspath(os.path.join(self.root, foldername)) # sanity tests diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index da77b5a..4ff98c3 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -298,6 +298,12 @@ class UIBase(object): (src_repo, dst_repo)) ############################## Folder syncing + def makefolder(self, repo, foldername): + """Called when a folder is created""" + prefix = "[DRYRUN] " if self.dryrun else "" + self.info("{}Creating folder {}[{}]".format( + prefix, foldername, repo)) + def syncingfolder(self, srcrepos, srcfolder, destrepos, destfolder): """Called when a folder sync operation is started.""" self.logger.info("Syncing %s: %s -> %s" % (srcfolder,