Hello, I just wrote a little patch (delta) to my current header cache, which makes it possible to have a *per folder* header cache. But it is different from MEs original patch which put the the hcache database in the Maildir itself (this isn't possible anyway because the current header cache implementation also provides hcacheing for imap). From the help: The header_chache variable points to the header cache database. If header_cache points to a directory there will be created one header cache database per folder within this directory. If it doesn't point to a directory a global header cache for all folders is used. Per default it is unset and so no header caching will be used. Please provide feedback if this is helpful and should be applied in the hcache. Some people have hache databases which are 190Mbyte and bigger. Of course they could use folder_hooks to obtain the same effect, but this way it is much easier to use. A big database slows down the hcaching a lot. (faui03) [/tmp/sithglan-hcache] ls -alh total 44368 drwxr-xr-x 2 sithglan icipguru 384 Sep 18 13:23 . drwxrwxrwt 19 root sys 3.4K Sep 18 13:30 .. -rw------- 1 sithglan icipguru 2.6M Sep 18 13:23 3d8953a1fd270ecf57bffc785310ec74 -rw------- 1 sithglan icipguru 2.6M Sep 18 13:23 76c37b683752469fce2207184cb85249 -rw------- 1 sithglan icipguru 17M Sep 18 13:22 b2932362d26987e33bd5b9ec9653758b ... Honestly, Thomas http://wwwcip.informatik.uni-erlangen.de/~sithglan/mutt/patch-1.5.6+20040918+hc.per_folder_hc.0
diff -Nru a/hcache.c b/hcache.c --- a/hcache.c 2004-09-02 14:27:26 +02:00 +++ b/hcache.c 2004-09-18 13:03:39 +02:00 @@ -37,6 +37,7 @@ #include "mime.h" #include "mx.h" #include "lib.h" +#include "md5.h" #if HAVE_GDBM static struct @@ -412,7 +413,7 @@ SPAM_LIST *sp = SpamList; RX_LIST *rx = NoSpamList; - crc = crc32(crc, (unsigned char const *) "sithglan@xxxxxxxxxxxxxxxxxxxx|hcache.c|20040902122726|65256", mutt_strlen("sithglan@xxxxxxxxxxxxxxxxxxxx|hcache.c|20040902122726|65256")); + crc = crc32(crc, (unsigned char const *) "sithglan@xxxxxxxxxxxxxxxxxxxx|hcache.c|20040918110339|18700", mutt_strlen("sithglan@xxxxxxxxxxxxxxxxxxxx|hcache.c|20040918110339|18700")); #if HAVE_LANGINFO_CODESET crc = crc32(crc, (unsigned char const *) Charset, mutt_strlen(Charset)); @@ -487,6 +488,45 @@ return d; } +/* Append md5sumed folder to path if path is a directory. */ + +static const char * +mutt_hcache_per_folder(const char *path, const char *folder) +{ + static char mutt_hcache_per_folder_path[_POSIX_PATH_MAX]; + struct stat path_stat; + MD5_CTX md5; + unsigned char md5sum[16]; + int ret; + + ret = stat(path, &path_stat); + if (ret < 0) { + return path; + } + + if (! S_ISDIR(path_stat.st_mode)) { + return path; + } + + MD5Init(&md5); + MD5Update(&md5, (unsigned char *) folder, strlen(folder)); + MD5Final(md5sum, &md5); + + ret = snprintf(mutt_hcache_per_folder_path, _POSIX_PATH_MAX, + "%s/%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x%02x%02x%02x%02x%02x%02x", + path, md5sum[0], md5sum[1], md5sum[2], md5sum[3], + md5sum[4], md5sum[5], md5sum[6], md5sum[7], md5sum[8], + md5sum[9], md5sum[10], md5sum[11], md5sum[12], + md5sum[13], md5sum[14], md5sum[15]); + + if (ret <= 0) { + return path; + } + + return mutt_hcache_per_folder_path; +} + HEADER * mutt_hcache_restore(const unsigned char *d, HEADER **oh) { @@ -537,6 +577,8 @@ return NULL; } + path = mutt_hcache_per_folder(path, folder); + h->db = gdbm_open((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL); if (h->db) { return h; @@ -678,6 +720,8 @@ FREE(& h); return NULL; } + + path = mutt_hcache_per_folder(path, folder); snprintf (h->lockfile, _POSIX_PATH_MAX, "%s-lock-hack", path); diff -Nru a/init.h b/init.h --- a/init.h 2004-08-26 22:31:23 +02:00 +++ b/init.h 2004-09-18 13:03:30 +02:00 @@ -1027,8 +1027,11 @@ { "header_cache", DT_PATH, R_NONE, UL &HeaderCache, 0 }, /* ** .pp - ** Path to the header cache file. If unset no cache will be used. Otherwise - ** the cache will be enabled for Maildir and IMAP mailboxes. + ** The header_chache variable points to the header cache database. If + ** header_cache points to a directory there will be created one header cache + ** database per folder within this directory. If it doesn't point to a directory a + ** global header cache for all folders is used. Per default it is unset and so + ** no header caching will be used. */ { "maildir_header_cache_verify", DT_BOOL, R_NONE, OPTHCACHEVERIFY, 1 }, /*
Attachment:
pgpSk767WlKDG.pgp
Description: PGP signature