diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index c199861..1ce9b85 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -295,7 +295,6 @@ class SyncableAccount(Account): # folder delimiter etc) remoterepos.getfolders() localrepos.getfolders() - statusrepos.getfolders() remoterepos.sync_folder_structure(localrepos, statusrepos) # replicate the folderstructure between REMOTE to LOCAL diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py index 3e5db2f..73a6a62 100644 --- a/offlineimap/repository/LocalStatus.py +++ b/offlineimap/repository/LocalStatus.py @@ -43,8 +43,8 @@ class LocalStatusRepository(BaseRepository): if not os.path.exists(self.root): os.mkdir(self.root, 0o700) - # self._folders is a list of LocalStatusFolders() - self._folders = None + # self._folders is a dict of name:LocalStatusFolders() + self._folders = {} def getsep(self): return '.' @@ -83,19 +83,23 @@ class LocalStatusRepository(BaseRepository): def getfolder(self, foldername): """Return the Folder() object for a foldername""" - return self.LocalStatusFolderClass(foldername, self) + if foldername in self._folders: + return self._folders[foldername] + + folder = self.LocalStatusFolderClass(foldername, self) + self._folders[foldername] = folder + return folder def getfolders(self): - """Returns a list of all cached folders.""" - if self._folders != None: - return self._folders + """Returns a list of all cached folders. - self._folders = [] - for folder in os.listdir(self.root): - self._folders.append(self.getfolder(folder)) - return self._folders + Does nothing for this backend. We mangle the folder file names + (see getfolderfilename) so we can not derive folder names from + the file names that we have available. TODO: need to store a + list of folder names somehow?""" + pass def forgetfolders(self): """Forgets the cached list of folders, if any. Useful to run after a sync run.""" - self._folders = None + self._folders = {}