From fda93c3798aa786328529588a40718df090d3dcc Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 24 Feb 2022 16:36:24 +0100 Subject: [PATCH] Better file exception handling on saving index JSON --- changedetectionio/store.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index c23bf204..5b69a955 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -398,13 +398,10 @@ class ChangeDetectionStore: # system was out of memory, out of RAM etc with open(self.json_store_path+".tmp", 'w') as json_file: json.dump(data, json_file, indent=4) - + os.rename(self.json_store_path+".tmp", self.json_store_path) except Exception as e: logging.error("Error writing JSON!! (Main JSON file save was skipped) : %s", str(e)) - else: - os.rename(self.json_store_path+".tmp", self.json_store_path) - self.needs_write = False # Thread runner, this helps with thread/write issues when there are many operations that want to update the JSON