From 41e275e9a288fa7a58c09f9f4951a4b184446d9f Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Sat, 9 Apr 2016 21:06:38 +0200 Subject: [PATCH] make sqlite status cache the default Signed-off-by: Nicolas Sebrecht --- docs/offlineimap.txt | 24 ++++++++++++++---------- offlineimap.conf | 20 +++++--------------- offlineimap/repository/LocalStatus.py | 6 +++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/docs/offlineimap.txt b/docs/offlineimap.txt index 111dc2c..672e74d 100644 --- a/docs/offlineimap.txt +++ b/docs/offlineimap.txt @@ -200,16 +200,20 @@ done this yet, do it :). See the folderfilter section in offlineimap.conf. 3. The cache. + -The default status cache is a plain text file that will write out the complete -file for each single new message (or even changed flag) to a temporary file. -If you have plenty of files in a folder, this is a few hundred kilo to -megabytes for each mail and is bound to make things slower. I recommend to use -the sqlite backend for that. See the status_backend = sqlite setting in the -offlineimap.conf. You will need to have python-sqlite installed in order to -use this. This will save you plenty of disk activity. Do note that -the sqlite backend is still considered experimental as it has only been -included recently (although a loss of your status cache should not be a -tragedy as that file can be rebuilt automatically) +OfflineImap caches the state of the synchronisation to e.g. be able to determine +if a mail has been added or deleted on either side. ++ +The historical status cache is a plain text file that writes out the complete +file for each single new message (or even changed flag) to a temporary file. If +you have plenty of files in a folder, this is a few hundred kilo to megabytes +for each mail and is bound to make things slow. The default status cache uses +sqlite. This saves plenty of disk activity. The sqlite engine and the Python +sqlite module must installed. See the status_backend = plain setting in the +offlineimap.conf. ++ +If you switch the backend from plain to sqlite, you may want to delete the old +cache directory in /Account-/LocalStatus manually once +you are sure that things work. 4. Use quick sync. + diff --git a/offlineimap.conf b/offlineimap.conf index 6f05dcc..f1a9daf 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -302,26 +302,16 @@ remoterepository = RemoteExample # # This example plays a sound file of your chosing when new mail arrives. # -#newmail_hook = lambda: os.system("cvlc --play-and-stop --play-and-exit /path/to/sound/file.mp3" + -# " > /dev/null 2>&1") +#newmail_hook = lambda: os.system( +#"cvlc --play-and-stop --play-and-exit /path/to/sound/file.mp3 > /dev/null 2>&1") # This option stands in the [Account Test] section. # -# OfflineImap caches the state of the synchronisation to e.g. be able to -# determine if a mail has been added or deleted on either side. +# The historical backend is 'plain' which writes out the state in plain text +# files. See manual. # -# The default and historical backend is 'plain' which writes out the -# state in plain text files. On Repositories with large numbers of -# mails, the performance might not be optimal, as we write out the -# complete file for each change. Another new backend 'sqlite' is -# available which stores the status in sqlite databases. -# -# If you switch the backend, you may want to delete the old cache -# directory in ~/.offlineimap/Account-/LocalStatus manually -# once you are sure that things work. -# -#status_backend = plain +#status_backend = sqlite # This option stands in the [Account Test] section. diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py index 5d33cdc..25fadc0 100644 --- a/offlineimap/repository/LocalStatus.py +++ b/offlineimap/repository/LocalStatus.py @@ -38,7 +38,7 @@ class LocalStatusRepository(BaseRepository): } # Set class and root for the configured backend - self.setup_backend(self.account.getconf('status_backend', 'plain')) + self.setup_backend(self.account.getconf('status_backend', 'sqlite')) if not os.path.exists(self.root): os.mkdir(self.root, 0o700) @@ -71,8 +71,8 @@ class LocalStatusRepository(BaseRepository): # if backend contains data, import it to folder. if not folderbk.isnewfolder(): - self.ui._msg('Migrating LocalStatus cache from %s to %s " \ - "status folder for %s:%s'% + self.ui._msg("Migrating LocalStatus cache from %s to %s " + "status folder for %s:%s"% (bk, self._backend, self.name, folder.name)) folderbk.cachemessagelist()