Catch json decode exception when semantic search stats file is corrupted

This commit is contained in:
Josh Hawkins 2025-07-29 12:49:10 -05:00
parent 4f4c8a4fb9
commit e51b3dd51e

View File

@ -7,6 +7,7 @@ import multiprocessing as mp
import os import os
import signal import signal
import threading import threading
from json.decoder import JSONDecodeError
from types import FrameType from types import FrameType
from typing import Any, Optional, Union from typing import Any, Optional, Union
@ -78,7 +79,7 @@ class EmbeddingsContext:
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: except (FileNotFoundError, JSONDecodeError):
pass pass
def stop(self): def stop(self):