/offlineimap/head: changeset 208

Added support for /-separated Maildirs -- that is, hierarchical
Maildir trees. Fixes [complete.org #28] and, for Debian, Closes:
#155460.
This commit is contained in:
jgoerzen 2002-08-08 03:40:18 +01:00
parent 7b44f609f0
commit cd6b343bb0
5 changed files with 37 additions and 11 deletions

View File

@ -10,6 +10,9 @@ offlineimap (3.2.2) unstable; urgency=low
* If a given Maildir folder is new, remove the associated local status
cache file, if any. That way, there will not be any chance of
propogating hordes of deletes and adds based on old status data.
* Added support for /-separated Maildirs -- that is, hierarchical
Maildir trees. Fixes [complete.org #28] and, for Debian,
Closes: #155460.
-- John Goerzen <jgoerzen@complete.org> Thu, 25 Jul 2002 08:22:25 -0500

View File

@ -277,3 +277,10 @@ holdconnectionopen = no
# are not both set.
# keepalive = 60
# You can specify the "path separator character" used for your Maildir
# folders. This is inserted in-between the components of the tree.
# It defaults to ".". If you want your Maildir folders to be nested,
# set it to "/".
sep = .

View File

@ -136,7 +136,7 @@ def syncaccount(accountname, *args):
remoterepos = repository.IMAP.IMAPRepository(config, accountname, server)
# Connect to the Maildirs.
localrepos = repository.Maildir.MaildirRepository(os.path.expanduser(config.get(accountname, "localfolders")))
localrepos = repository.Maildir.MaildirRepository(os.path.expanduser(config.get(accountname, "localfolders")), accountname, config)
# Connect to the local cache.
statusrepos = repository.LocalStatus.LocalStatusRepository(accountmetadata)

View File

@ -39,10 +39,10 @@ def gettimeseq():
return timeseq
class MaildirFolder(BaseFolder):
def __init__(self, root, name):
def __init__(self, root, name, sep):
self.name = name
self.root = root
self.sep = '.'
self.sep = sep
self.uidfilename = os.path.join(self.getfullname(), "offlineimap.uidvalidity")
self.messagelist = None

View File

@ -22,31 +22,46 @@ from mailbox import Maildir
import os
class MaildirRepository(BaseRepository):
def __init__(self, root):
def __init__(self, root, accountname, config):
"""Initialize a MaildirRepository object. Takes a path name
to the directory holding all the Maildir directories."""
self.root = root
self.folders = None
self.accountname = accountname
self.config = config
def getsep(self):
return '.'
if self.config.has_option(self.accountname, 'sep'):
return self.config.get(self.accountname, 'sep').strip()
else:
return '.'
def makefolder(self, foldername):
folderdir = os.path.join(self.root, foldername)
os.mkdir(folderdir, 0700)
# Do the chdir thing so the call to makedirs does not make the
# self.root directory (we'd prefer to raise an error in that case),
# but will make the (relative) paths underneath it. Need to use
# makedirs to support a / separator.
if os.getsep() == '/':
for invalid in ['new', 'cur', 'tmp', 'offlineimap.uidvalidity']:
for component in foldername.split('/'):
assert component != invalid, "When using nested folders (/ as a separator in the account config), your folder names may not contain 'new', 'cur', 'tmp', or 'offlineimap.uidvalidity'."
oldcwd = os.getcwd()
os.chdir(self.root)
os.makedirs(folderdir, 0700)
for subdir in ['cur', 'new', 'tmp']:
os.mkdir(os.path.join(folderdir, subdir), 0700)
# Invalidate the cache
self.folders = None
os.chdir(oldcwd)
def deletefolder(self, foldername):
print "NOT YET IMPLEMENTED: DELETE FOLDER %s" % foldername
def getfolder(self, foldername):
return folder.Maildir.MaildirFolder(self.root, foldername)
return folder.Maildir.MaildirFolder(self.root, foldername,
self.getsep())
def getfolders(self):
if self.folders != None:
@ -61,7 +76,8 @@ class MaildirRepository(BaseRepository):
os.path.isdir(os.path.join(fullname, 'new')) and
os.path.isdir(os.path.join(fullname, 'tmp'))):
continue
retval.append(folder.Maildir.MaildirFolder(self.root, dirname))
retval.append(folder.Maildir.MaildirFolder(self.root, dirname,
self.getsep()))
self.folders = retval
return retval