Correctly update fallback_to_date_header setting in case we are unable to load the...
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 5 Jul 2012 09:07:54 +0000 (11:07 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 5 Jul 2012 09:07:54 +0000 (11:07 +0200)
src/caching_data.py

index ab3e4ad..d9b9359 100644 (file)
@@ -42,9 +42,9 @@ class CachingData:
             cache_info, self.data = pickle.load(cachefile)
             cache_info = cache_info.split(' ')
             self.version = cache_info[0]
+            self.fallback_to_date_header = cache_info[1]
             if(self.version != CACHE_VERSION):
                 raise IOError("Cache file has version %s and the script version is %s" % (self.version, CACHE_VERSION))
-            self.fallback_to_date_header = cache_info[1]
             if(self.fallback_to_date_header != str(fallback_mode)):
                 raise IOError("Cache file date fallback mode setting is different than current settings")
             logging.info("Cache file %s loaded", CACHE_FILENAME)
@@ -53,7 +53,8 @@ class CachingData:
             logging.warning("Couldn't load cache file %s: %s", CACHE_FILENAME, ex)
             logging.warning("DELETING CACHE")
             self.version = CACHE_VERSION
-            stored_cache_info = self.version + ' ' + str(fallback_mode)
+            self.fallback_to_date_header = str(fallback_mode)
+            stored_cache_info = self.version + ' ' + self.fallback_to_date_header
             self.data = {}
             with open(CACHE_FILENAME, 'wb') as cachefile:
                 pickle.dump((stored_cache_info, self.data), cachefile)