Complete.Org: Mailing Lists: Archives: offlineimap: March 2008:
[PATCH 2/2] Commit ever 100 updateflags requests
Home

[PATCH 2/2] Commit ever 100 updateflags requests

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: offlineimap@xxxxxxxxxxxx
Cc: Stewart Smith <stewart@willster (none)>
Subject: [PATCH 2/2] Commit ever 100 updateflags requests
From: stewart@xxxxxxxxxxxxxxxx
Date: Mon, 31 Mar 2008 15:52:10 +1100

From: Stewart Smith <stewart@willster.(none)>

Improves syncing large status changes by about a factor of 100

100 is arbitrary. Seems like an acceptable number to have to redo
if crash
---
 offlineimap/folder/LocalStatus.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/offlineimap/folder/LocalStatus.py 
b/offlineimap/folder/LocalStatus.py
index 90ad3c8..86738b0 100644
--- a/offlineimap/folder/LocalStatus.py
+++ b/offlineimap/folder/LocalStatus.py
@@ -41,6 +41,7 @@ class LocalStatusFolder(BaseFolder):
         self.savelock = threading.Lock()
         self.doautosave = 1
         self.accountname = accountname
+        self.count = 0 # used for batching operations before commit
         BaseFolder.__init__(self)
        self.dbfilename = self.filename + '.sqlite'
 
@@ -184,7 +185,10 @@ class LocalStatusFolder(BaseFolder):
         flags.sort()
         flags = ''.join(flags)
         self.cursor.execute('UPDATE status SET flags=? WHERE id=?',(flags,uid))
-        self.autosave()
+        self.count = self.count + 1
+        if self.count == 100:
+            self.autosave()
+            self.count = 0
 
     def deletemessage(self, uid):
         if not self.uidexists(uid):
-- 
1.5.3.GIT




[Prev in Thread] Current Thread [Next in Thread]