From d44bbbcc905d0e3791026ab6470b7c93fc8a2883 Mon Sep 17 00:00:00 2001 From: gsd Date: Sun, 1 Sep 2024 21:48:34 +0300 Subject: [PATCH] preview load timeout fix 2 --- backend/config_parser.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/config_parser.py b/backend/config_parser.py index 29cfaaf..d7b74e3 100644 --- a/backend/config_parser.py +++ b/backend/config_parser.py @@ -301,10 +301,15 @@ class TranscodeTools: async for chunk in nvr.stream_file(file, preview_pre_bytes): await raw.write(chunk) except asyncio.TimeoutError as te: - idx = self.preview_storage.index(preview_file) - del self.preview_storage[idx] + try: + idx = self.preview_storage.index(preview_file) + del self.preview_storage[idx] + except: + self.preview_storage = [] + self.logger.info(f"Cancel download file: {te}") - os.remove(raw_file) + if os.path.exists(raw_file): + os.remove(raw_file) finally: nvr.logout()