Adapt plain status folder to gmail labels stuff
* Implements Status Folder format v2, with a mechanism to upgrade an old statusfolder. * Do not warn about Gmail and GmailMaildir needing sqlite backend anymore. * Clean repository.LocalStatus reusing some code from folder.LocalStatus. * Change field separator in the plaintext file from ':' to '|'. Now the local status stores gmail labels. If they contain field separator character (formerly ':'), they get messed up. The new character '|' is less likely to appear in a label. Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:

committed by
Eygene Ryabinkin

parent
789e047734
commit
09556d645e
@ -36,12 +36,6 @@ class GmailRepository(IMAPRepository):
|
||||
'ssl', 'yes')
|
||||
IMAPRepository.__init__(self, reposname, account)
|
||||
|
||||
if self.account.getconfboolean('synclabels', 0) and \
|
||||
self.account.getconf('status_backend', 'plain') != 'sqlite':
|
||||
raise OfflineImapError("The Gmail repository needs the sqlite backend to sync labels.\n"
|
||||
"To enable it add 'status_backend = sqlite' in the account section",
|
||||
OfflineImapError.ERROR.REPO)
|
||||
|
||||
|
||||
def gethost(self):
|
||||
"""Return the server name to connect to.
|
||||
|
@ -25,12 +25,6 @@ class GmailMaildirRepository(MaildirRepository):
|
||||
"""Initialize a MaildirRepository object. Takes a path name
|
||||
to the directory holding all the Maildir directories."""
|
||||
super(GmailMaildirRepository, self).__init__(reposname, account)
|
||||
if self.account.getconfboolean('synclabels', 0) and \
|
||||
self.account.getconf('status_backend', 'plain') != 'sqlite':
|
||||
raise OfflineImapError("The GmailMaildir repository needs the sqlite backend to sync labels.\n"
|
||||
"To enable it add 'status_backend = sqlite' in the account section",
|
||||
OfflineImapError.ERROR.REPO)
|
||||
|
||||
|
||||
|
||||
def getfoldertype(self):
|
||||
|
@ -16,7 +16,7 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
from offlineimap.folder.LocalStatus import LocalStatusFolder, magicline
|
||||
from offlineimap.folder.LocalStatus import LocalStatusFolder
|
||||
from offlineimap.folder.LocalStatusSQLite import LocalStatusSQLiteFolder
|
||||
from offlineimap.repository.Base import BaseRepository
|
||||
import os
|
||||
@ -49,19 +49,6 @@ class LocalStatusRepository(BaseRepository):
|
||||
def getsep(self):
|
||||
return '.'
|
||||
|
||||
def getfolderfilename(self, foldername):
|
||||
"""Return the full path of the status file
|
||||
|
||||
This mimics the path that Folder().getfolderbasename() would return"""
|
||||
if not foldername:
|
||||
basename = '.'
|
||||
else: #avoid directory hierarchies and file names such as '/'
|
||||
basename = foldername.replace('/', '.')
|
||||
# replace with literal 'dot' if final path name is '.' as '.' is
|
||||
# an invalid file name.
|
||||
basename = re.sub('(^|\/)\.$','\\1dot', basename)
|
||||
return os.path.join(self.root, basename)
|
||||
|
||||
def makefolder(self, foldername):
|
||||
"""Create a LocalStatus Folder
|
||||
|
||||
@ -73,11 +60,10 @@ class LocalStatusRepository(BaseRepository):
|
||||
if self.account.dryrun:
|
||||
return # bail out in dry-run mode
|
||||
|
||||
filename = self.getfolderfilename(foldername)
|
||||
file = open(filename + ".tmp", "wt")
|
||||
file.write(magicline + '\n')
|
||||
file.close()
|
||||
os.rename(filename + ".tmp", filename)
|
||||
# Create an empty StatusFolder
|
||||
folder = self.LocalStatusFolderClass(foldername, self)
|
||||
folder.save()
|
||||
|
||||
# Invalidate the cache.
|
||||
self._folders = {}
|
||||
|
||||
|
Reference in New Issue
Block a user