/offlineimap/head: changeset 294

Updated with various fixes
This commit is contained in:
jgoerzen 2003-01-03 08:01:41 +01:00
parent 09828a9d4f
commit 8e3b18f375
2 changed files with 24 additions and 11 deletions

View File

@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from Base import BaseFolder from Base import BaseFolder
import os import os, threading
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1" magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
@ -29,6 +29,8 @@ class LocalStatusFolder(BaseFolder):
self.filename = os.path.join(root, name) self.filename = os.path.join(root, name)
self.messagelist = None self.messagelist = None
self.repository = repository self.repository = repository
self.savelock = threading.Lock()
self.doautosave = 1
def storesmessages(self): def storesmessages(self):
return 0 return 0
@ -68,16 +70,24 @@ class LocalStatusFolder(BaseFolder):
self.messagelist[uid] = {'uid': uid, 'flags': flags} self.messagelist[uid] = {'uid': uid, 'flags': flags}
file.close() file.close()
def autosave(self):
if self.doautosave:
self.save()
def save(self): def save(self):
file = open(self.filename + ".tmp", "wt") self.savelock.acquire()
file.write(magicline + "\n") try:
for msg in self.messagelist.values(): file = open(self.filename + ".tmp", "wt")
flags = msg['flags'] file.write(magicline + "\n")
flags.sort() for msg in self.messagelist.values():
flags = ''.join(flags) flags = msg['flags']
file.write("%s:%s\n" % (msg['uid'], flags)) flags.sort()
file.close() flags = ''.join(flags)
os.rename(self.filename + ".tmp", self.filename) file.write("%s:%s\n" % (msg['uid'], flags))
file.close()
os.rename(self.filename + ".tmp", self.filename)
finally:
self.savelock.release()
def getmessagelist(self): def getmessagelist(self):
return self.messagelist return self.messagelist
@ -92,6 +102,7 @@ class LocalStatusFolder(BaseFolder):
return uid return uid
self.messagelist[uid] = {'uid': uid, 'flags': flags} self.messagelist[uid] = {'uid': uid, 'flags': flags}
self.autosave()
return uid return uid
def getmessageflags(self, uid): def getmessageflags(self, uid):
@ -99,9 +110,10 @@ class LocalStatusFolder(BaseFolder):
def savemessageflags(self, uid, flags): def savemessageflags(self, uid, flags):
self.messagelist[uid]['flags'] = flags self.messagelist[uid]['flags'] = flags
self.autosave()
def deletemessage(self, uid): def deletemessage(self, uid):
if not uid in self.messagelist: if not uid in self.messagelist:
return return
del(self.messagelist[uid]) del(self.messagelist[uid])
self.autosave()

View File

@ -165,6 +165,7 @@ class VerboseUI(UIBase):
self.created.wait() self.created.wait()
del self.created del self.created
time.sleep(1)
if doidlevac: if doidlevac:
t = threadutil.ExitNotifyThread(target = self.idlevacuum, t = threadutil.ExitNotifyThread(target = self.idlevacuum,