Implement ui.makefolder and abort repo.makefolder() in dry-run mode
IMAP, Maildir, and LocalStatus abort if in dry-run mode. IMAP and Maildir will log that they "would have" created a new folder. This will probably fail later on as we can not cache messagelists on folder that don't exist, so --dry-run is not yet safe when new folders have been created. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
33f55b5362
commit
b6807355b5
@ -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):
|
||||
|
@ -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. "
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user