/head: changeset 66

Bug fixes
This commit is contained in:
jgoerzen 2002-07-04 02:58:12 +01:00
parent 45e6279680
commit cabb768745
3 changed files with 68 additions and 54 deletions

View File

@ -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,14 +97,30 @@ 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():
server.connectionwait()
thread = Thread(target = syncfolder,
name = "syncfolder-%s-%s" % \
(accountname, remotefolder.getvisiblename()),
args = (accountname, remoterepos,
remotefolder, localrepos, statusrepos))
thread.start()
folderthreads.append(thread)
threadutil.threadsreset(folderthreads)
server.close()
finally:
accountsemaphore.release()
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
statusrepos):
mailboxes.append({'accountname': accountname, mailboxes.append({'accountname': accountname,
'foldername': remotefolder.getvisiblename()}) 'foldername': remotefolder.getvisiblename()})
# Load local folder. # Load local folder.
localfolder = localrepos.getfolder(remotefolder.getvisiblename()) localfolder = localrepos.getfolder(remotefolder.getvisiblename())
if not localfolder.isuidvalidityok(remotefolder): if not localfolder.isuidvalidityok(remotefolder):
ui.validityproblem(remotefolder) ui.validityproblem(remotefolder)
continue return
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder) ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
ui.loadmessagelist(localrepos, localfolder) ui.loadmessagelist(localrepos, localfolder)
localfolder.cachemessagelist() localfolder.cachemessagelist()
@ -142,9 +159,7 @@ def syncaccount(accountname):
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder) ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
localfolder.syncmessagesto(statusfolder) localfolder.syncmessagesto(statusfolder)
statusfolder.save() statusfolder.save()
server.close()
finally:
accountsemaphore.release()
def syncitall(): def syncitall():
mailboxes = [] # Reset. mailboxes = [] # Reset.
@ -152,12 +167,12 @@ def syncitall():
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)

View File

@ -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):

View File

@ -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