/head: changeset 13

Checkpointing
This commit is contained in:
jgoerzen 2002-06-20 05:14:54 +01:00
parent 2701b3f054
commit e760d9facb
2 changed files with 19 additions and 7 deletions

View File

@ -84,16 +84,22 @@ class BaseFolder:
for uid in self.getmessagelist().keys(): for uid in self.getmessagelist().keys():
if not uid in dest.getmessagelist(): if not uid in dest.getmessagelist():
dest.savemessage(uid, self.getmessage(uid)) message = self.getmessage(uid)
dest.savemessageflags(uid, self.getmessageflags(uid)) flags = self.getmessageflags(uid)
for object in applyto:
object.savemessage(uid, message)
object.savemessageflags(uid, flags)
# Pass 2 -- Look for message present in dest but not in self. # Pass 2 -- Look for message present in dest but not in self.
# If any, delete them. # If any, delete them.
for uid in dest.getmessagelist().keys(): for uid in dest.getmessagelist().keys():
if not uid in self.getmessagelist(): if not uid in self.getmessagelist():
dest.deletemessage(uid) for object in applyto:
object.deletemessage(uid)
# Now, the message lists should be identical wrt the uids present. # Now, the message lists should be identical wrt the uids present.
# Pass 3 -- Look for any # Pass 3 -- Look for any flag identity issues.

View File

@ -58,13 +58,21 @@ class MaildirFolder(BaseFolder):
and must occur in ASCII order.""" and must occur in ASCII order."""
self.messagelist = {} self.messagelist = {}
files = [] files = []
nouidcounter = -1 # Messages without UIDs get
# negative UID numbers.
for dirannex in ['new', 'cur']: for dirannex in ['new', 'cur']:
fulldirname = os.path.join(self.getfullname(), dirannex) fulldirname = os.path.join(self.getfullname(), dirannex)
files.append([os.path.join(fulldirname, filename) for files.append([os.path.join(fulldirname, filename) for
filename in os.listdir(fulldirname)]) filename in os.listdir(fulldirname)])
for file in files: for file in files:
messagename = os.path.basename(file) messagename = os.path.basename(file)
uid = int(re.search(',U=(\d+)', messagename).group(1)) uidmatch = re.search(',U=(\d+)', messagename)
uid = None
if not uidmatch:
uid = nouidcounter
nouidcounter -= 1
else:
uid = int(uidmatch.group(1))
flagmatch = re.search(':.*2,([A-Z]+)') flagmatch = re.search(':.*2,([A-Z]+)')
flags = [] flags = []
if flagmatch: if flagmatch:
@ -74,8 +82,6 @@ class MaildirFolder(BaseFolder):
'filename': messagename} 'filename': messagename}
def getmessagelist(self): def getmessagelist(self):
if self.messagelist == None:
self.cachemessagelist()
return self.messagelist return self.messagelist