Adds 'Create Copy' feature to clone a watch (#184)

This commit is contained in:
Matthias Langhard
2021-08-26 22:10:17 +02:00
committed by GitHub
parent 54d80ddea0
commit 05f7e123ed
3 changed files with 33 additions and 0 deletions

View File

@@ -242,6 +242,27 @@ class ChangeDetectionStore:
self.needs_write = True
# Clone a watch by UUID
def clone(self, uuid):
with self.lock:
new_uuid = str(uuid_builder.uuid4())
_clone = deepcopy(self.data['watching'][uuid])
_clone.update({'uuid': new_uuid})
attributes_to_reset = [
'last_checked',
'last_changed',
'last_viewed',
'newest_history_key',
'previous_md5',
'history'
]
for attribute in attributes_to_reset:
_clone.update({attribute: self.generic_definition[attribute]})
self.data['watching'][new_uuid] = _clone
self.needs_write = True
def url_exists(self, url):
# Probably their should be dict...