diff --git a/fanficfare/browsercache/__init__.py b/fanficfare/browsercache/__init__.py index 752cb96b..43e8641b 100644 --- a/fanficfare/browsercache/__init__.py +++ b/fanficfare/browsercache/__init__.py @@ -40,6 +40,7 @@ class BrowserCache(object): getConfigList_fn) if self.browser_cache_impl is not None: break + logger.debug("Not using Browser Cache Class %s"%browser_cache_class) if self.browser_cache_impl is None: raise BrowserCacheException("%s is not set, or directory does not contain a known browser cache type: '%s'"% (CACHE_DIR_CONFIG,getConfig_fn(CACHE_DIR_CONFIG))) diff --git a/fanficfare/browsercache/browsercache_blockfile.py b/fanficfare/browsercache/browsercache_blockfile.py index 71d519d0..a5643343 100644 --- a/fanficfare/browsercache/browsercache_blockfile.py +++ b/fanficfare/browsercache/browsercache_blockfile.py @@ -90,18 +90,23 @@ class BlockfileCache(BaseChromiumCache): def is_cache_dir(cache_dir): """Return True only if a directory is a valid Cache for this class""" if not os.path.isdir(cache_dir): + logger.debug("Cache dir not found") return False index_path = os.path.join(cache_dir, "index") if not os.path.isfile(index_path): + logger.debug("index file not found") return False with share_open(index_path, 'rb') as index_file: if struct.unpack('I', index_file.read(4))[0] != INDEX_MAGIC_NUMBER: + logger.debug("index file failed magic number check") return False data0_path = os.path.join(cache_dir, "data_0") if not os.path.isfile(data0_path): + logger.debug("data_0 file not found") return False with share_open(data0_path, 'rb') as data0_file: if struct.unpack('I', data0_file.read(4))[0] != BLOCK_MAGIC_NUMBER: + logger.debug("data_0 failed magic number check") return False return True diff --git a/fanficfare/browsercache/browsercache_firefox2.py b/fanficfare/browsercache/browsercache_firefox2.py index 20b7bd62..b19ebcd0 100644 --- a/fanficfare/browsercache/browsercache_firefox2.py +++ b/fanficfare/browsercache/browsercache_firefox2.py @@ -68,6 +68,7 @@ class FirefoxCache2(BaseBrowserCache): """Return True only if a directory is a valid Cache for this class""" # logger.debug("\n\n1Starting cache check\n\n") if not os.path.isdir(cache_dir): + logger.debug("Cache dir not found") return False ## check at least one entry file exists. for en_fl in glob.iglob(os.path.join(cache_dir, 'entries', '????????????????????????????????????????')): @@ -75,6 +76,7 @@ class FirefoxCache2(BaseBrowserCache): k = _validate_entry_file(en_fl) if k is not None: return True + logger.debug("No valid cache files found") return False def make_keys(self,url): diff --git a/fanficfare/browsercache/browsercache_simple.py b/fanficfare/browsercache/browsercache_simple.py index 3e4a35b8..df820e4e 100644 --- a/fanficfare/browsercache/browsercache_simple.py +++ b/fanficfare/browsercache/browsercache_simple.py @@ -76,15 +76,19 @@ class SimpleCache(BaseChromiumCache): def is_cache_dir(cache_dir): """Return True only if a directory is a valid Cache for this class""" if not os.path.isdir(cache_dir): + logger.debug("Cache dir not found") return False index_file = os.path.join(cache_dir, "index") if not (os.path.isfile(index_file) and os.path.getsize(index_file) == 24): + logger.debug("index file not found or wrong size(%s)"%os.path.getsize(index_file)) return False real_index_file = os.path.join(cache_dir, "index-dir", "the-real-index") if not os.path.isfile(real_index_file): + logger.debug("real_index_file not found") return False with share_open(real_index_file, 'rb') as index_file: if struct.unpack('QQ', index_file.read(16))[1] != THE_REAL_INDEX_MAGIC_NUMBER: + logger.debug("real_index_file failed magic number check") return False try: # logger.debug("\n\nStarting cache check\n\n") @@ -92,9 +96,11 @@ class SimpleCache(BaseChromiumCache): k = _validate_entry_file(en_fl) if k is not None: return True - except SimpleCacheException: + except SimpleCacheException as sce: # raise + logger.debug(sce) return False + logger.debug("No valid cache files found") return False def get_data_key_impl(self, url, key):