From 73485475e9ddb049739f82d67c14eea703573ebd Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Sun, 2 Mar 2008 22:17:45 -0600 Subject: [PATCH 1/2] Infrastructure for notifying LocalStatus of local mailbox creations This will let us delete LocalStatus caches when we create a local mailbox refs deb#459985, refs #19 --- offlineimap/accounts.py | 2 +- offlineimap/repository/Base.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 9f224d0..8e96347 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -145,7 +145,7 @@ class AccountSynchronizationMixin: localrepos = self.localrepos statusrepos = self.statusrepos self.ui.syncfolders(remoterepos, localrepos) - remoterepos.syncfoldersto(localrepos) + remoterepos.syncfoldersto(localrepos, [statusrepos]) folderthreads = [] for remotefolder in remoterepos.getfolders(): diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py index 93e464b..0486dfc 100644 --- a/offlineimap/repository/Base.py +++ b/offlineimap/repository/Base.py @@ -125,9 +125,12 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): def getfolder(self, foldername): raise NotImplementedError - def syncfoldersto(self, dest): + def syncfoldersto(self, dest, copyfolders): """Syncs the folders in this repository to those in dest. - It does NOT sync the contents of those folders.""" + It does NOT sync the contents of those folders. + + For every time dest.makefolder() is called, also call makefolder() + on each folder in copyfolders.""" src = self srcfolders = src.getfolders() destfolders = dest.getfolders() @@ -150,6 +153,8 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): for key in srchash.keys(): if not key in desthash: dest.makefolder(key) + for copyfolder in copyfolders: + copyfolder.makefolder(key) # # Find deleted folders. From 2094037de1eff3efdd468d2cca6366b7863feed1 Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Sun, 2 Mar 2008 22:21:10 -0600 Subject: [PATCH 2/2] Truncate local status folders on creation Should help eliminate problems with old cache refs deb#459985, refs #19 --- offlineimap/repository/LocalStatus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py index c30e1f1..0a13706 100644 --- a/offlineimap/repository/LocalStatus.py +++ b/offlineimap/repository/LocalStatus.py @@ -37,8 +37,8 @@ class LocalStatusRepository(BaseRepository): return os.path.join(self.directory, foldername) def makefolder(self, foldername): - # "touch" the file. - file = open(self.getfolderfilename(foldername), "ab") + # "touch" the file, truncating it. + file = open(self.getfolderfilename(foldername), "wb") file.close() # Invalidate the cache. self.folders = None