minor code refactoring
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
@@ -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):
|
||||
|
@@ -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):
|
||||
|
@@ -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),
|
||||
|
Reference in New Issue
Block a user