Deleting a watch now removes the entire watch storage directory (#1408)

pull/1410/head
dgtlmoon 2023-02-11 14:10:54 +01:00 zatwierdzone przez GitHub
rodzic 01af21f856
commit 7b8b50138b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 8 dodań i 11 usunięć

Wyświetl plik

@ -192,27 +192,24 @@ class ChangeDetectionStore:
tags.sort()
return tags
def unlink_history_file(self, path):
try:
unlink(path)
except (FileNotFoundError, IOError):
pass
# Delete a single watch by UUID
def delete(self, uuid):
import pathlib
import shutil
with self.lock:
if uuid == 'all':
self.__data['watching'] = {}
# GitHub #30 also delete history records
for uuid in self.data['watching']:
for path in self.data['watching'][uuid].history.values():
self.unlink_history_file(path)
path = pathlib.Path(os.path.join(self.datastore_path, uuid))
shutil.rmtree(path)
self.needs_write_urgent = True
else:
for path in self.data['watching'][uuid].history.values():
self.unlink_history_file(path)
path = pathlib.Path(os.path.join(self.datastore_path, uuid))
shutil.rmtree(path)
del self.data['watching'][uuid]
self.needs_write_urgent = True