/head: changeset 66
Bug fixes
This commit is contained in:
parent
45e6279680
commit
cabb768745
@ -53,10 +53,10 @@ accountsemaphore = BoundedSemaphore(config.getint("general", "maxsyncaccounts"))
|
|||||||
# asking for passwords simultaneously.
|
# asking for passwords simultaneously.
|
||||||
|
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if config.has_option(accountname, "remotepass"):
|
if config.has_option(account, "remotepass"):
|
||||||
passwords[account] = config.get(accountname, "remotepass")
|
passwords[account] = config.get(account, "remotepass")
|
||||||
else:
|
else:
|
||||||
passwords[account] = ui.getpass(accountname, config)
|
passwords[account] = ui.getpass(account, config)
|
||||||
|
|
||||||
mailboxes = []
|
mailboxes = []
|
||||||
mailboxlock = Lock()
|
mailboxlock = Lock()
|
||||||
@ -66,7 +66,8 @@ def addmailbox(accountname, remotefolder):
|
|||||||
'foldername': remotefolder.getvisiblename()})
|
'foldername': remotefolder.getvisiblename()})
|
||||||
mailboxlock.release()
|
mailboxlock.release()
|
||||||
|
|
||||||
def syncaccount(accountname):
|
def syncaccount(accountname, *args):
|
||||||
|
print args
|
||||||
# We don't need an account lock because syncitall() goes through
|
# We don't need an account lock because syncitall() goes through
|
||||||
# each account once, then waits for all to finish.
|
# each account once, then waits for all to finish.
|
||||||
accountsemaphore.acquire()
|
accountsemaphore.acquire()
|
||||||
@ -96,68 +97,82 @@ def syncaccount(accountname):
|
|||||||
ui.syncfolders(remoterepos, localrepos)
|
ui.syncfolders(remoterepos, localrepos)
|
||||||
remoterepos.syncfoldersto(localrepos)
|
remoterepos.syncfoldersto(localrepos)
|
||||||
|
|
||||||
|
folderthreads = []
|
||||||
for remotefolder in remoterepos.getfolders():
|
for remotefolder in remoterepos.getfolders():
|
||||||
mailboxes.append({'accountname': accountname,
|
server.connectionwait()
|
||||||
'foldername': remotefolder.getvisiblename()})
|
thread = Thread(target = syncfolder,
|
||||||
# Load local folder.
|
name = "syncfolder-%s-%s" % \
|
||||||
localfolder = localrepos.getfolder(remotefolder.getvisiblename())
|
(accountname, remotefolder.getvisiblename()),
|
||||||
if not localfolder.isuidvalidityok(remotefolder):
|
args = (accountname, remoterepos,
|
||||||
ui.validityproblem(remotefolder)
|
remotefolder, localrepos, statusrepos))
|
||||||
continue
|
thread.start()
|
||||||
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
|
folderthreads.append(thread)
|
||||||
ui.loadmessagelist(localrepos, localfolder)
|
threadutil.threadsreset(folderthreads)
|
||||||
localfolder.cachemessagelist()
|
|
||||||
ui.messagelistloaded(localrepos, localfolder, len(localfolder.getmessagelist().keys()))
|
|
||||||
|
|
||||||
# Load remote folder.
|
|
||||||
ui.loadmessagelist(remoterepos, remotefolder)
|
|
||||||
remotefolder.cachemessagelist()
|
|
||||||
ui.messagelistloaded(remoterepos, remotefolder,
|
|
||||||
len(remotefolder.getmessagelist().keys()))
|
|
||||||
|
|
||||||
# Load status folder.
|
|
||||||
statusfolder = statusrepos.getfolder(remotefolder.getvisiblename())
|
|
||||||
statusfolder.cachemessagelist()
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
if not statusfolder.isnewfolder():
|
|
||||||
# Delete local copies of remote messages. This way,
|
|
||||||
# if a message's flag is modified locally but it has been
|
|
||||||
# deleted remotely, we'll delete it locally. Otherwise, we
|
|
||||||
# try to modify a deleted message's flags! This step
|
|
||||||
# need only be taken if a statusfolder is present; otherwise,
|
|
||||||
# there is no action taken *to* the remote repository.
|
|
||||||
|
|
||||||
remotefolder.syncmessagesto_delete(localfolder, [localfolder,
|
|
||||||
statusfolder])
|
|
||||||
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
|
|
||||||
localfolder.syncmessagesto(statusfolder, [remotefolder, statusfolder])
|
|
||||||
|
|
||||||
# Synchronize remote changes.
|
|
||||||
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
|
||||||
remotefolder.syncmessagesto(localfolder)
|
|
||||||
|
|
||||||
# Make sure the status folder is up-to-date.
|
|
||||||
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
|
|
||||||
localfolder.syncmessagesto(statusfolder)
|
|
||||||
statusfolder.save()
|
|
||||||
server.close()
|
server.close()
|
||||||
finally:
|
finally:
|
||||||
accountsemaphore.release()
|
accountsemaphore.release()
|
||||||
|
|
||||||
|
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
||||||
|
statusrepos):
|
||||||
|
mailboxes.append({'accountname': accountname,
|
||||||
|
'foldername': remotefolder.getvisiblename()})
|
||||||
|
# Load local folder.
|
||||||
|
localfolder = localrepos.getfolder(remotefolder.getvisiblename())
|
||||||
|
if not localfolder.isuidvalidityok(remotefolder):
|
||||||
|
ui.validityproblem(remotefolder)
|
||||||
|
return
|
||||||
|
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
|
||||||
|
ui.loadmessagelist(localrepos, localfolder)
|
||||||
|
localfolder.cachemessagelist()
|
||||||
|
ui.messagelistloaded(localrepos, localfolder, len(localfolder.getmessagelist().keys()))
|
||||||
|
|
||||||
|
# Load remote folder.
|
||||||
|
ui.loadmessagelist(remoterepos, remotefolder)
|
||||||
|
remotefolder.cachemessagelist()
|
||||||
|
ui.messagelistloaded(remoterepos, remotefolder,
|
||||||
|
len(remotefolder.getmessagelist().keys()))
|
||||||
|
|
||||||
|
# Load status folder.
|
||||||
|
statusfolder = statusrepos.getfolder(remotefolder.getvisiblename())
|
||||||
|
statusfolder.cachemessagelist()
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
if not statusfolder.isnewfolder():
|
||||||
|
# Delete local copies of remote messages. This way,
|
||||||
|
# if a message's flag is modified locally but it has been
|
||||||
|
# deleted remotely, we'll delete it locally. Otherwise, we
|
||||||
|
# try to modify a deleted message's flags! This step
|
||||||
|
# need only be taken if a statusfolder is present; otherwise,
|
||||||
|
# there is no action taken *to* the remote repository.
|
||||||
|
|
||||||
|
remotefolder.syncmessagesto_delete(localfolder, [localfolder,
|
||||||
|
statusfolder])
|
||||||
|
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
|
||||||
|
localfolder.syncmessagesto(statusfolder, [remotefolder, statusfolder])
|
||||||
|
|
||||||
|
# Synchronize remote changes.
|
||||||
|
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
||||||
|
remotefolder.syncmessagesto(localfolder)
|
||||||
|
|
||||||
|
# Make sure the status folder is up-to-date.
|
||||||
|
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
|
||||||
|
localfolder.syncmessagesto(statusfolder)
|
||||||
|
statusfolder.save()
|
||||||
|
|
||||||
|
|
||||||
def syncitall():
|
def syncitall():
|
||||||
mailboxes = [] # Reset.
|
mailboxes = [] # Reset.
|
||||||
threads = []
|
threads = []
|
||||||
for accountname in accounts:
|
for accountname in accounts:
|
||||||
threadutil.semaphorewait(accountsemaphore)
|
threadutil.semaphorewait(accountsemaphore)
|
||||||
thread = Thread(target = syncaccount,
|
thread = Thread(target = syncaccount,
|
||||||
name = "syncaccount %s" % accountname,
|
name = "syncaccount-%s" % accountname,
|
||||||
args = (accountname))
|
args = (accountname,))
|
||||||
thread.start()
|
thread.start()
|
||||||
threads.append(thread)
|
threads.append(thread)
|
||||||
# Wait for the threads to finish.
|
# Wait for the threads to finish.
|
||||||
threadutil.threadreset(threads)
|
threadutil.threadsreset(threads)
|
||||||
|
|
||||||
mbnames.genmbnames(config, mailboxes)
|
mbnames.genmbnames(config, mailboxes)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
try:
|
try:
|
||||||
imapobj.select(self.getfullname())
|
imapobj.select(self.getfullname())
|
||||||
self.messagelist = {}
|
self.messagelist = {}
|
||||||
response = self.imapobj.status(self.getfullname(), '(MESSAGES)')[1][0]
|
response = imapobj.status(self.getfullname(), '(MESSAGES)')[1][0]
|
||||||
result = imaputil.imapsplit(response)[1]
|
result = imaputil.imapsplit(response)[1]
|
||||||
maxmsgid = long(imaputil.flags2hash(result)['MESSAGES'])
|
maxmsgid = long(imaputil.flags2hash(result)['MESSAGES'])
|
||||||
if (maxmsgid < 1):
|
if (maxmsgid < 1):
|
||||||
|
@ -28,7 +28,6 @@ class UsefulIMAPMixIn:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def select(self, mailbox='INBOX', readonly=None):
|
def select(self, mailbox='INBOX', readonly=None):
|
||||||
print "Mixin select"
|
|
||||||
if self.getselectedfolder() == mailbox and not readonly:
|
if self.getselectedfolder() == mailbox and not readonly:
|
||||||
# No change; return.
|
# No change; return.
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user