/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
from Base import BaseFolder
import os
import os, threading
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.messagelist = None
self.repository = repository
self.savelock = threading.Lock()
self.doautosave = 1
def storesmessages(self):
return 0
@ -68,7 +70,13 @@ class LocalStatusFolder(BaseFolder):
self.messagelist[uid] = {'uid': uid, 'flags': flags}
file.close()
def autosave(self):
if self.doautosave:
self.save()
def save(self):
self.savelock.acquire()
try:
file = open(self.filename + ".tmp", "wt")
file.write(magicline + "\n")
for msg in self.messagelist.values():
@ -78,6 +86,8 @@ class LocalStatusFolder(BaseFolder):
file.write("%s:%s\n" % (msg['uid'], flags))
file.close()
os.rename(self.filename + ".tmp", self.filename)
finally:
self.savelock.release()
def getmessagelist(self):
return self.messagelist
@ -92,6 +102,7 @@ class LocalStatusFolder(BaseFolder):
return uid
self.messagelist[uid] = {'uid': uid, 'flags': flags}
self.autosave()
return uid
def getmessageflags(self, uid):
@ -99,9 +110,10 @@ class LocalStatusFolder(BaseFolder):
def savemessageflags(self, uid, flags):
self.messagelist[uid]['flags'] = flags
self.autosave()
def deletemessage(self, uid):
if not uid in self.messagelist:
return
del(self.messagelist[uid])
self.autosave()

View File

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