diff --git a/changedetectionio/api/Watch.py b/changedetectionio/api/Watch.py index a208fbaa..ac7ebcf4 100644 --- a/changedetectionio/api/Watch.py +++ b/changedetectionio/api/Watch.py @@ -73,6 +73,9 @@ class Watch(Resource): # Create a dict copy for JSON response (with lock for thread safety) # This is much faster than deepcopy and doesn't copy the datastore reference + # WARNING: dict() is a SHALLOW copy - nested dicts are shared with original! + # Only safe because we only ADD scalar properties (line 97-101), never modify nested dicts + # If you need to modify nested dicts, use: from copy import deepcopy; watch = deepcopy(dict(watch_obj)) with self.datastore.lock: watch = dict(watch_obj) diff --git a/changedetectionio/store/__init__.py b/changedetectionio/store/__init__.py index 137876cf..435d9835 100644 --- a/changedetectionio/store/__init__.py +++ b/changedetectionio/store/__init__.py @@ -541,8 +541,9 @@ class ChangeDetectionStore(DatastoreUpdatesMixin, FileSavingDataStore): # Clone a watch by UUID def clone(self, uuid): url = self.data['watching'][uuid].get('url') - # No need to deepcopy here - add_watch() will deepcopy extras anyway - # Just pass the watch object directly (with lock for thread safety) + # No need to deepcopy here - add_watch() will deepcopy extras anyway (line 569) + # Just pass a dict copy (with lock for thread safety) + # NOTE: dict() is shallow copy but safe since add_watch() deepcopies it with self.lock: extras = dict(self.data['watching'][uuid]) new_uuid = self.add_watch(url=url, extras=extras)