/offlineimap/head: changeset 294
Updated with various fixes
This commit is contained in:
parent
09828a9d4f
commit
8e3b18f375
@ -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()
|
||||
|
@ -165,6 +165,7 @@ class VerboseUI(UIBase):
|
||||
|
||||
self.created.wait()
|
||||
del self.created
|
||||
time.sleep(1)
|
||||
|
||||
if doidlevac:
|
||||
t = threadutil.ExitNotifyThread(target = self.idlevacuum,
|
||||
|
Loading…
Reference in New Issue
Block a user