kopia lustrzana https://github.com/dgtlmoon/changedetection.io
System - No need to run updates on fresh installs (#1854)
rodzic
aa6ad7bf47
commit
7ace259d70
|
@ -96,6 +96,14 @@ class ChangeDetectionStore:
|
||||||
self.add_watch(url='https://changedetection.io/CHANGELOG.txt',
|
self.add_watch(url='https://changedetection.io/CHANGELOG.txt',
|
||||||
tag='changedetection.io',
|
tag='changedetection.io',
|
||||||
extras={'fetch_backend': 'html_requests'})
|
extras={'fetch_backend': 'html_requests'})
|
||||||
|
|
||||||
|
updates_available = self.get_updates_available()
|
||||||
|
self.__data['settings']['application']['schema_version'] = updates_available.pop()
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Bump the update version by running updates
|
||||||
|
self.run_updates()
|
||||||
|
|
||||||
self.__data['version_tag'] = version_tag
|
self.__data['version_tag'] = version_tag
|
||||||
|
|
||||||
# Just to test that proxies.json if it exists, doesnt throw a parsing error on startup
|
# Just to test that proxies.json if it exists, doesnt throw a parsing error on startup
|
||||||
|
@ -125,9 +133,6 @@ class ChangeDetectionStore:
|
||||||
secret = secrets.token_hex(16)
|
secret = secrets.token_hex(16)
|
||||||
self.__data['settings']['application']['api_access_token'] = secret
|
self.__data['settings']['application']['api_access_token'] = secret
|
||||||
|
|
||||||
# Bump the update version by running updates
|
|
||||||
self.run_updates()
|
|
||||||
|
|
||||||
self.needs_write = True
|
self.needs_write = True
|
||||||
|
|
||||||
# Finally start the thread that will manage periodic data saves to JSON
|
# Finally start the thread that will manage periodic data saves to JSON
|
||||||
|
@ -625,14 +630,8 @@ class ChangeDetectionStore:
|
||||||
def tag_exists_by_name(self, tag_name):
|
def tag_exists_by_name(self, tag_name):
|
||||||
return any(v.get('title', '').lower() == tag_name.lower() for k, v in self.__data['settings']['application']['tags'].items())
|
return any(v.get('title', '').lower() == tag_name.lower() for k, v in self.__data['settings']['application']['tags'].items())
|
||||||
|
|
||||||
# Run all updates
|
def get_updates_available(self):
|
||||||
# IMPORTANT - Each update could be run even when they have a new install and the schema is correct
|
|
||||||
# So therefor - each `update_n` should be very careful about checking if it needs to actually run
|
|
||||||
# Probably we should bump the current update schema version with each tag release version?
|
|
||||||
def run_updates(self):
|
|
||||||
import inspect
|
import inspect
|
||||||
import shutil
|
|
||||||
|
|
||||||
updates_available = []
|
updates_available = []
|
||||||
for i, o in inspect.getmembers(self, predicate=inspect.ismethod):
|
for i, o in inspect.getmembers(self, predicate=inspect.ismethod):
|
||||||
m = re.search(r'update_(\d+)$', i)
|
m = re.search(r'update_(\d+)$', i)
|
||||||
|
@ -640,6 +639,15 @@ class ChangeDetectionStore:
|
||||||
updates_available.append(int(m.group(1)))
|
updates_available.append(int(m.group(1)))
|
||||||
updates_available.sort()
|
updates_available.sort()
|
||||||
|
|
||||||
|
return updates_available
|
||||||
|
|
||||||
|
# Run all updates
|
||||||
|
# IMPORTANT - Each update could be run even when they have a new install and the schema is correct
|
||||||
|
# So therefor - each `update_n` should be very careful about checking if it needs to actually run
|
||||||
|
# Probably we should bump the current update schema version with each tag release version?
|
||||||
|
def run_updates(self):
|
||||||
|
import shutil
|
||||||
|
updates_available = self.get_updates_available()
|
||||||
for update_n in updates_available:
|
for update_n in updates_available:
|
||||||
if update_n > self.__data['settings']['application']['schema_version']:
|
if update_n > self.__data['settings']['application']['schema_version']:
|
||||||
print ("Applying update_{}".format((update_n)))
|
print ("Applying update_{}".format((update_n)))
|
||||||
|
|
Ładowanie…
Reference in New Issue