|
|
@ -260,46 +260,14 @@ class ChangeDetectionStore:
|
|
|
|
return self.data['watching'][uuid].get(val)
|
|
|
|
return self.data['watching'][uuid].get(val)
|
|
|
|
|
|
|
|
|
|
|
|
# Remove a watchs data but keep the entry (URL etc)
|
|
|
|
# Remove a watchs data but keep the entry (URL etc)
|
|
|
|
def scrub_watch(self, uuid, limit_timestamp = False):
|
|
|
|
def scrub_watch(self, uuid):
|
|
|
|
|
|
|
|
import pathlib
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
del_timestamps = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
changes_removed = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for timestamp, path in self.data['watching'][uuid]['history'].items():
|
|
|
|
|
|
|
|
if not limit_timestamp or (limit_timestamp is not False and int(timestamp) > limit_timestamp):
|
|
|
|
|
|
|
|
self.unlink_history_file(path)
|
|
|
|
|
|
|
|
del_timestamps.append(timestamp)
|
|
|
|
|
|
|
|
changes_removed += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not limit_timestamp:
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['last_checked'] = 0
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['last_changed'] = 0
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['previous_md5'] = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for timestamp in del_timestamps:
|
|
|
|
|
|
|
|
del self.data['watching'][uuid]['history'][str(timestamp)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If there was a limitstamp, we need to reset some meta data about the entry
|
|
|
|
|
|
|
|
# This has to happen after we remove the others from the list
|
|
|
|
|
|
|
|
if limit_timestamp:
|
|
|
|
|
|
|
|
newest_key = self.get_newest_history_key(uuid)
|
|
|
|
|
|
|
|
if newest_key:
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['last_checked'] = int(newest_key)
|
|
|
|
|
|
|
|
# @todo should be the original value if it was less than newest key
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['last_changed'] = int(newest_key)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
with open(self.data['watching'][uuid]['history'][str(newest_key)], "rb") as fp:
|
|
|
|
|
|
|
|
content = fp.read()
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['previous_md5'] = hashlib.md5(content).hexdigest()
|
|
|
|
|
|
|
|
except (FileNotFoundError, IOError):
|
|
|
|
|
|
|
|
self.data['watching'][uuid]['previous_md5'] = ""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.needs_write = True
|
|
|
|
self.__data['watching'][uuid].update({'history': {}, 'last_checked': 0, 'last_changed': 0, 'newest_history_key': 0, 'previous_md5': False})
|
|
|
|
return changes_removed
|
|
|
|
self.needs_write_urgent = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for item in pathlib.Path(self.datastore_path).rglob(uuid+"/*.txt"):
|
|
|
|
|
|
|
|
unlink(item)
|
|
|
|
|
|
|
|
|
|
|
|
def add_watch(self, url, tag="", extras=None, write_to_disk_now=True):
|
|
|
|
def add_watch(self, url, tag="", extras=None, write_to_disk_now=True):
|
|
|
|
if extras is None:
|
|
|
|
if extras is None:
|
|
|
@ -453,10 +421,11 @@ class ChangeDetectionStore:
|
|
|
|
import pathlib
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
|
|
# Only in the sub-directories
|
|
|
|
# Only in the sub-directories
|
|
|
|
for item in pathlib.Path(self.datastore_path).rglob("*/*txt"):
|
|
|
|
for uuid in self.data['watching']:
|
|
|
|
if not str(item) in index:
|
|
|
|
for item in pathlib.Path(self.datastore_path).rglob(uuid+"/*.txt"):
|
|
|
|
print ("Removing",item)
|
|
|
|
if not str(item) in index:
|
|
|
|
unlink(item)
|
|
|
|
print ("Removing",item)
|
|
|
|
|
|
|
|
unlink(item)
|
|
|
|
|
|
|
|
|
|
|
|
# Run all updates
|
|
|
|
# Run all updates
|
|
|
|
# IMPORTANT - Each update could be run even when they have a new install and the schema is correct
|
|
|
|
# IMPORTANT - Each update could be run even when they have a new install and the schema is correct
|
|
|
|