Skip to content

High performance self-hosted photo and video management solution.

fix(ml): clear cache if bad zip file (#3600)

Mertfa57853bd2ed
diff --git a/machine-learning/app/models/base.py b/machine-learning/app/models/base.py
index 8c3a06fc92..9bdbb08b31 100644
--- a/machine-learning/app/models/base.py
+++ b/machine-learning/app/models/base.py
@@ -4,6 +4,7 @@ from abc import ABC, abstractmethod
from pathlib import Path
from shutil import rmtree
from typing import Any
+from zipfile import BadZipFile
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidProtobuf # type: ignore
@@ -23,7 +24,7 @@ class InferenceModel(ABC):
loader = self.load if eager else self.download
try:
loader(**model_kwargs)
- except (OSError, InvalidProtobuf):
+ except (OSError, InvalidProtobuf, BadZipFile):
self.clear_cache()
loader(**model_kwargs)