This commit is contained in:
dgtlmoon
2023-03-19 16:03:13 +01:00
parent d597a861b9
commit 88b37d5783
2 changed files with 8 additions and 7 deletions
+4 -4
View File
@@ -850,14 +850,14 @@ def changedetection_app(config=None, datastore_o=None):
# Read as binary and force decode as UTF-8
# Windows may fail decode in python if we just use 'r' mode (chardet decode exception)
try:
newest_version_file_contents = watch.get_history_snapshot(history[dates[-1]])
newest_version_file_contents = watch.get_history_snapshot(dates[-1])
except Exception as e:
newest_version_file_contents = "Unable to read {}.\n".format(history[dates[-1]])
newest_version_file_contents = "Unable to read {}.\n".format(dates[-1])
previous_version = request.args.get('previous_version')
previous_timestamp = history[dates[-2]]
previous_timestamp = dates[-2]
if previous_version:
previous_timestamp= previous_version
previous_timestamp = previous_version
try:
previous_version_file_contents = watch.get_history_snapshot(previous_timestamp)
+4 -3
View File
@@ -241,6 +241,10 @@ class model(dict):
bump = self.history
return self.__newest_history_key
def get_history_snapshot(self, timestamp):
with open(self.history[timestamp], 'r', encoding='utf-8', errors='ignore') as f:
return f.read()
# Save some text file to the appropriate path and bump the history
# result_obj from fetch_site_status.run()
def save_history_text(self, contents, timestamp, snapshot_id):
@@ -359,9 +363,6 @@ class model(dict):
return fname
return False
def get_history_snapshot(self, timestamp):
with open(self.history[timestamp], 'rb', encoding='utf-8', errors='ignore') as f:
return f.read()
def pause(self):
self['paused'] = True