Fix AI processor cache initialization issue and create empty cache file
This commit is contained in:
parent
6ce68a9037
commit
e9c66da456
@ -25,10 +25,24 @@ class CacheManager:
|
|||||||
if os.path.exists(self.cache_file):
|
if os.path.exists(self.cache_file):
|
||||||
with open(self.cache_file, 'r', encoding='utf-8') as f:
|
with open(self.cache_file, 'r', encoding='utf-8') as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
return {}
|
else:
|
||||||
|
# Create empty cache file if it doesn't exist
|
||||||
|
cache_data = {
|
||||||
|
"cache_version": "1.0",
|
||||||
|
"created": datetime.now().isoformat(),
|
||||||
|
"processed_files": {}
|
||||||
|
}
|
||||||
|
self.cache = cache_data
|
||||||
|
self._save_cache()
|
||||||
|
return cache_data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error loading cache file {self.cache_file}: {e}")
|
logger.error(f"Error loading cache file {self.cache_file}: {e}")
|
||||||
return {}
|
# Return empty cache on error
|
||||||
|
return {
|
||||||
|
"cache_version": "1.0",
|
||||||
|
"created": datetime.now().isoformat(),
|
||||||
|
"processed_files": {}
|
||||||
|
}
|
||||||
|
|
||||||
def _save_cache(self) -> None:
|
def _save_cache(self) -> None:
|
||||||
"""Save cache to file."""
|
"""Save cache to file."""
|
||||||
|
|||||||
5
ai_processor/processed_articles_cache.json
Normal file
5
ai_processor/processed_articles_cache.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"cache_version": "1.0",
|
||||||
|
"created": "2026-02-02T15:43:08.000Z",
|
||||||
|
"processed_files": {}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user