/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.
for account in accounts:
if config.has_option(accountname, "remotepass"):
passwords[account] = config.get(accountname, "remotepass")
if config.has_option(account, "remotepass"):
passwords[account] = config.get(account, "remotepass")
else:
passwords[account] = ui.getpass(accountname, config)
passwords[account] = ui.getpass(account, config)
mailboxes = []
mailboxlock = Lock()
@ -66,7 +66,8 @@ def addmailbox(accountname, remotefolder):
'foldername': remotefolder.getvisiblename()})
mailboxlock.release()
def syncaccount(accountname):
def syncaccount(accountname, *args):
print args
# We don't need an account lock because syncitall() goes through
# each account once, then waits for all to finish.
accountsemaphore.acquire()
@ -96,14 +97,30 @@ def syncaccount(accountname):
ui.syncfolders(remoterepos, localrepos)
remoterepos.syncfoldersto(localrepos)
folderthreads = []
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,
'foldername': remotefolder.getvisiblename()})
# Load local folder.
localfolder = localrepos.getfolder(remotefolder.getvisiblename())
if not localfolder.isuidvalidityok(remotefolder):
ui.validityproblem(remotefolder)
continue
return
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
ui.loadmessagelist(localrepos, localfolder)
localfolder.cachemessagelist()
@ -142,9 +159,7 @@ def syncaccount(accountname):
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
localfolder.syncmessagesto(statusfolder)
statusfolder.save()
server.close()
finally:
accountsemaphore.release()
def syncitall():
mailboxes = [] # Reset.
@ -152,12 +167,12 @@ def syncitall():
for accountname in accounts:
threadutil.semaphorewait(accountsemaphore)
thread = Thread(target = syncaccount,
name = "syncaccount %s" % accountname,
args = (accountname))
name = "syncaccount-%s" % accountname,
args = (accountname,))
thread.start()
threads.append(thread)
# Wait for the threads to finish.
threadutil.threadreset(threads)
threadutil.threadsreset(threads)
mbnames.genmbnames(config, mailboxes)

View File

@ -53,7 +53,7 @@ class IMAPFolder(BaseFolder):
try:
imapobj.select(self.getfullname())
self.messagelist = {}
response = self.imapobj.status(self.getfullname(), '(MESSAGES)')[1][0]
response = imapobj.status(self.getfullname(), '(MESSAGES)')[1][0]
result = imaputil.imapsplit(response)[1]
maxmsgid = long(imaputil.flags2hash(result)['MESSAGES'])
if (maxmsgid < 1):

View File

@ -28,7 +28,6 @@ class UsefulIMAPMixIn:
return None
def select(self, mailbox='INBOX', readonly=None):
print "Mixin select"
if self.getselectedfolder() == mailbox and not readonly:
# No change; return.
return