mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
clear stats file if corrupted
This commit is contained in:
parent
e51b3dd51e
commit
0e107a7fb5
@ -74,13 +74,21 @@ class EmbeddingsContext:
|
|||||||
self.requestor = EmbeddingsRequestor()
|
self.requestor = EmbeddingsRequestor()
|
||||||
|
|
||||||
# load stats from disk
|
# load stats from disk
|
||||||
|
stats_file = os.path.join(CONFIG_DIR, ".search_stats.json")
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(CONFIG_DIR, ".search_stats.json"), "r") as f:
|
with open(stats_file, "r") as f:
|
||||||
data = json.loads(f.read())
|
data = json.loads(f.read())
|
||||||
self.thumb_stats.from_dict(data["thumb_stats"])
|
self.thumb_stats.from_dict(data["thumb_stats"])
|
||||||
self.desc_stats.from_dict(data["desc_stats"])
|
self.desc_stats.from_dict(data["desc_stats"])
|
||||||
except (FileNotFoundError, JSONDecodeError):
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
except JSONDecodeError:
|
||||||
|
logger.warning("Failed to decode semantic search stats, clearing file")
|
||||||
|
try:
|
||||||
|
with open(stats_file, "w") as f:
|
||||||
|
f.write("")
|
||||||
|
except OSError as e:
|
||||||
|
logger.error(f"Failed to clear corrupted stats file: {e}")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""Write the stats to disk as JSON on exit."""
|
"""Write the stats to disk as JSON on exit."""
|
||||||
|
Loading…
Reference in New Issue
Block a user