never overwrite old backups, create new ones always

This commit is contained in:
dgtlmoon committed 2025-11-10 14:07:40 +01:00
1 parent bb89b4ca83
commit 3ba75764e3
1 file changed
+8 -1
+8 -1
View File
@@ -770,7 +770,14 @@ class ChangeDetectionStore:
logger.critical(f"Applying update_{update_n}")
# Wont exist on fresh installs
if os.path.exists(self.json_store_path):
shutil.copyfile(self.json_store_path, os.path.join(self.datastore_path, f"url-watches-before-{update_n}.json"))
i = 0
while True:
i+=1
dest = os.path.join(self.datastore_path, f"url-watches-before-{update_n}-{i}.json")
if not os.path.exists(dest):
logger.debug(f"Copying url-watches.json DB to '{dest}' backup.")
shutil.copyfile(self.json_store_path, dest)
break
try:
update_method = getattr(self, f"update_{update_n}")()