diff --git a/offlineimap.conf b/offlineimap.conf index cf2776c..a730484 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -540,6 +540,7 @@ localfolders = ~/Test # #filename_use_mail_timestamp = no + # This option stands in the [Repository LocalExample] section. # # Map IMAP [user-defined] keywords to lowercase letters, similar to Dovecot's diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 45fddfc..46671c1 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -453,15 +453,10 @@ def syncfolder(account, remotefolder, quick): localfolder.save_uidvalidity() remotefolder.save_uidvalidity() - def save_min_uid(folder, min_uid): - uidfile = folder.get_min_uid_file() - fd = open(uidfile, 'wt') - fd.write(str(min_uid) + "\n") - fd.close() - - def cachemessagelists_upto_date(localfolder, remotefolder, date): + def cachemessagelists_upto_date(date): """Returns messages with uid > min(uids of messages newer than date).""" + # Warning: this makes sense only if the cached list is empty. localfolder.cachemessagelist(min_date=date) check_uid_validity(localfolder, remotefolder, statusfolder) # Local messagelist had date restriction applied already. Restrict @@ -515,7 +510,7 @@ def syncfolder(account, remotefolder, quick): min_uid = min(positive_uids) else: min_uid = 1 - save_min_uid(partial, min_uid) + partial.save_min_uid(min_uid) else: partial.cachemessagelist(min_uid=min_uid) @@ -562,7 +557,7 @@ def syncfolder(account, remotefolder, quick): ui.warn("Quick syncs (-q) not supported in conjunction " "with maxage or startdate; ignoring -q.") if maxage != None: - cachemessagelists_upto_date(localfolder, remotefolder, maxage) + cachemessagelists_upto_date(maxage) elif localstart != None: cachemessagelists_startdate(remotefolder, localfolder, localstart) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 4b2b78b..5f287fa 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -400,6 +400,12 @@ class BaseFolder(object): os.mkdir(startuiddir, 0o700) return os.path.join(startuiddir, self.getfolderbasename()) + def save_min_uid(self, min_uid): + uidfile = self.get_min_uid_file() + fd = open(uidfile, 'wt') + fd.write(str(min_uid) + "\n") + fd.close() + def retrieve_min_uid(self): uidfile = self.get_min_uid_file() if not os.path.exists(uidfile): diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py index d172f58..47c7144 100644 --- a/offlineimap/folder/LocalStatusSQLite.py +++ b/offlineimap/folder/LocalStatusSQLite.py @@ -91,7 +91,6 @@ class LocalStatusSQLiteFolder(BaseFolder): if self.filename not in LocalStatusSQLiteFolder.locks: LocalStatusSQLiteFolder.locks[self.filename] = DatabaseFileLock() self._databaseFileLock = LocalStatusSQLiteFolder.locks[self.filename] - self._in_transactions = 0 def __enter__(self): diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index e00e727..7998912 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -34,14 +34,16 @@ except NameError: from offlineimap import OfflineImapError, emailutil from .Base import BaseFolder + # Find the UID in a message filename re_uidmatch = re.compile(',U=(\d+)') # Find a numeric timestamp in a string (filename prefix) -re_timestampmatch = re.compile('(\d+)'); +re_timestampmatch = re.compile('(\d+)') timehash = {} timelock = Lock() + def _gettimeseq(date=None): global timehash, timelock timelock.acquire() @@ -56,6 +58,7 @@ def _gettimeseq(date=None): finally: timelock.release() + class MaildirFolder(BaseFolder): def __init__(self, root, name, sep, repository): self.sep = sep # needs to be set before super().__init__ @@ -343,6 +346,7 @@ class MaildirFolder(BaseFolder): See folder/Base for detail. Note that savemessage() does not check against dryrun settings, so you need to ensure that savemessage is never called in a dryrun mode.""" + # This function only ever saves to tmp/, # but it calls savemessageflags() to actually save to cur/ or new/. self.ui.savemessage('maildir', uid, flags, self) @@ -471,6 +475,8 @@ class MaildirFolder(BaseFolder): oldfilename = self.messagelist[uid]['filename'] dir_prefix, filename = os.path.split(oldfilename) flags = self.getmessageflags(uid) + # TODO: we aren't keeping the prefix timestamp so we don't honor the + # filename_use_mail_timestamp configuration option. newfilename = os.path.join(dir_prefix, self.new_message_filename(new_uid, flags)) os.rename(os.path.join(self.getfullname(), oldfilename),