mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-12 20:46:17 +00:00
Compare commits
4 Commits
remove-unu
...
delete-sho
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86717e52f6 | ||
|
|
01af21f856 | ||
|
|
f7f4ab314b | ||
|
|
ce0355c0ad |
@@ -505,41 +505,6 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
output = render_template("clear_all_history.html")
|
output = render_template("clear_all_history.html")
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
# If they edited an existing watch, we need to know to reset the current/previous md5 to include
|
|
||||||
# the excluded text.
|
|
||||||
def get_current_checksum_include_ignore_text(uuid):
|
|
||||||
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
from changedetectionio import fetch_site_status
|
|
||||||
|
|
||||||
# Get the most recent one
|
|
||||||
newest_history_key = datastore.data['watching'][uuid].get('newest_history_key')
|
|
||||||
|
|
||||||
# 0 means that theres only one, so that there should be no 'unviewed' history available
|
|
||||||
if newest_history_key == 0:
|
|
||||||
newest_history_key = list(datastore.data['watching'][uuid].history.keys())[0]
|
|
||||||
|
|
||||||
if newest_history_key:
|
|
||||||
with open(datastore.data['watching'][uuid].history[newest_history_key],
|
|
||||||
encoding='utf-8') as file:
|
|
||||||
raw_content = file.read()
|
|
||||||
|
|
||||||
handler = fetch_site_status.perform_site_check(datastore=datastore)
|
|
||||||
stripped_content = html_tools.strip_ignore_text(raw_content,
|
|
||||||
datastore.data['watching'][uuid]['ignore_text'])
|
|
||||||
|
|
||||||
if datastore.data['settings']['application'].get('ignore_whitespace', False):
|
|
||||||
checksum = hashlib.md5(stripped_content.translate(None, b'\r\n\t ')).hexdigest()
|
|
||||||
else:
|
|
||||||
checksum = hashlib.md5(stripped_content).hexdigest()
|
|
||||||
|
|
||||||
return checksum
|
|
||||||
|
|
||||||
return datastore.data['watching'][uuid]['previous_md5']
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/edit/<string:uuid>", methods=['GET', 'POST'])
|
@app.route("/edit/<string:uuid>", methods=['GET', 'POST'])
|
||||||
@login_optionally_required
|
@login_optionally_required
|
||||||
# https://stackoverflow.com/questions/42984453/wtforms-populate-form-with-data-if-data-exists
|
# https://stackoverflow.com/questions/42984453/wtforms-populate-form-with-data-if-data-exists
|
||||||
@@ -946,7 +911,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
is_html_webdriver = False
|
is_html_webdriver = False
|
||||||
if (watch.get('fetch_backend') == 'system' and system_uses_webdriver) or watch.get('fetch_backend') == 'html_webdriver':
|
if (watch.get('fetch_backend') == 'system' and system_uses_webdriver) or watch.get('fetch_backend') == 'html_webdriver':
|
||||||
is_html_webdriver = True
|
is_html_webdriver = True
|
||||||
|
|
||||||
# Never requested successfully, but we detected a fetch error
|
# Never requested successfully, but we detected a fetch error
|
||||||
if datastore.data['watching'][uuid].history_n == 0 and (watch.get_error_text() or watch.get_error_snapshot()):
|
if datastore.data['watching'][uuid].history_n == 0 and (watch.get_error_text() or watch.get_error_snapshot()):
|
||||||
flash("Preview unavailable - No fetch/check completed or triggers not reached", "error")
|
flash("Preview unavailable - No fetch/check completed or triggers not reached", "error")
|
||||||
@@ -1036,7 +1001,8 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
os.unlink(previous_backup_filename)
|
os.unlink(previous_backup_filename)
|
||||||
|
|
||||||
# create a ZipFile object
|
# create a ZipFile object
|
||||||
backupname = "changedetection-backup-{}.zip".format(int(time.time()))
|
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
|
backupname = "changedetection-backup-{}.zip".format(timestamp)
|
||||||
backup_filepath = os.path.join(datastore_o.datastore_path, backupname)
|
backup_filepath = os.path.join(datastore_o.datastore_path, backupname)
|
||||||
|
|
||||||
with zipfile.ZipFile(backup_filepath, "w",
|
with zipfile.ZipFile(backup_filepath, "w",
|
||||||
|
|||||||
@@ -153,7 +153,9 @@ class model(dict):
|
|||||||
@property
|
@property
|
||||||
def is_pdf(self):
|
def is_pdf(self):
|
||||||
# content_type field is set in the future
|
# content_type field is set in the future
|
||||||
return '.pdf' in self.get('url', '').lower() or 'pdf' in self.get('content_type', '').lower()
|
# https://github.com/dgtlmoon/changedetection.io/issues/1392
|
||||||
|
# Not sure the best logic here
|
||||||
|
return self.get('url', '').lower().endswith('.pdf') or 'pdf' in self.get('content_type', '').lower()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def label(self):
|
def label(self):
|
||||||
|
|||||||
@@ -192,27 +192,24 @@ class ChangeDetectionStore:
|
|||||||
tags.sort()
|
tags.sort()
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
def unlink_history_file(self, path):
|
|
||||||
try:
|
|
||||||
unlink(path)
|
|
||||||
except (FileNotFoundError, IOError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Delete a single watch by UUID
|
# Delete a single watch by UUID
|
||||||
def delete(self, uuid):
|
def delete(self, uuid):
|
||||||
|
import pathlib
|
||||||
|
import shutil
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if uuid == 'all':
|
if uuid == 'all':
|
||||||
self.__data['watching'] = {}
|
self.__data['watching'] = {}
|
||||||
|
|
||||||
# GitHub #30 also delete history records
|
# GitHub #30 also delete history records
|
||||||
for uuid in self.data['watching']:
|
for uuid in self.data['watching']:
|
||||||
for path in self.data['watching'][uuid].history.values():
|
path = pathlib.Path(os.path.join(self.datastore_path, uuid))
|
||||||
self.unlink_history_file(path)
|
shutil.rmtree(path)
|
||||||
|
self.needs_write_urgent = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for path in self.data['watching'][uuid].history.values():
|
path = pathlib.Path(os.path.join(self.datastore_path, uuid))
|
||||||
self.unlink_history_file(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
del self.data['watching'][uuid]
|
del self.data['watching'][uuid]
|
||||||
|
|
||||||
self.needs_write_urgent = True
|
self.needs_write_urgent = True
|
||||||
|
|||||||
Reference in New Issue
Block a user