From 4bbb7d99b611b200e06fce8efbc94f91d7e66204 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 28 Oct 2021 11:29:59 +0200 Subject: [PATCH] Re #264 - fixing clone watch operation --- changedetectionio/__init__.py | 5 ++--- changedetectionio/store.py | 22 ++++------------------ 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 18839a61..39b3c0fa 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -778,9 +778,9 @@ def changedetection_app(config=None, datastore_o=None): @app.route("/api/clone", methods=['GET']) @login_required def api_clone(): - uuid = request.args.get('uuid') - datastore.clone(uuid) + new_uuid = datastore.clone(uuid) + update_q.put(new_uuid) flash('Cloned.') return redirect(url_for('index')) @@ -902,7 +902,6 @@ def ticker_thread_check_time_launch_checks(): # Check for watches outside of the time threshold to put in the thread queue. for uuid, watch in copied_datastore.data['watching'].items(): - # If they supplied an individual entry minutes to threshold. if 'minutes_between_check' in watch and watch['minutes_between_check'] is not None: # Cast to int just incase diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 0102f6e0..ebd04acc 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -251,24 +251,10 @@ class ChangeDetectionStore: # 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 + url = self.data['watching'][uuid]['url'] + tag = self.data['watching'][uuid]['tag'] + new_uuid = self.add_watch(url=url, tag=tag) + return new_uuid def url_exists(self, url):