]> granicus.if.org Git - mutt/commitdiff
Try to unlink old header cache if open fails
authorBrendan Cully <brendan@kublai.com>
Wed, 11 Apr 2007 02:28:14 +0000 (19:28 -0700)
committerBrendan Cully <brendan@kublai.com>
Wed, 11 Apr 2007 02:28:14 +0000 (19:28 -0700)
hcache.c

index 89e3d66da87d0171901f81d47abcb4678e4c47d1..d0dbeff595738b669ef21488ef71db4d9b0159a6 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -982,6 +982,7 @@ mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
 {
   struct header_cache *h = safe_calloc(1, sizeof (HEADER_CACHE));
   int (*hcache_open) (struct header_cache* h, const char* path);
+  struct stat sb;
 
 #if HAVE_QDBM
   hcache_open = hcache_open_qdbm;
@@ -1008,6 +1009,12 @@ mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
     return h;
   else
   {
+    /* remove a possibly incompatible version */
+    if (!stat (path, &sb) && !unlink (path))
+    {
+      if (!hcache_open (h, path))
+        return h;
+    }
     FREE(&h->folder);
     FREE(&h);