mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Fix plugins errors when reloading with a select and upgrade check
This commit is contained in:
parent
b6b87fcb03
commit
7f47ac18c0
2 changed files with 19 additions and 12 deletions
|
|
@ -1135,10 +1135,10 @@ class Database:
|
|||
updates[Plugins.method] = plugin["method"]
|
||||
|
||||
if plugin.get("data") != db_plugin.data:
|
||||
updates[Plugins.data] = plugin["data"]
|
||||
updates[Plugins.data] = plugin.get("data")
|
||||
|
||||
if plugin.get("checksum") != db_plugin.checksum:
|
||||
updates[Plugins.checksum] = plugin["checksum"]
|
||||
updates[Plugins.checksum] = plugin.get("checksum")
|
||||
|
||||
if updates:
|
||||
session.query(Plugins).filter(
|
||||
|
|
@ -1152,7 +1152,7 @@ class Database:
|
|||
.all()
|
||||
)
|
||||
db_ids = [setting.id for setting in db_plugin_settings]
|
||||
setting_ids = [setting["id"] for setting in settings.values()]
|
||||
setting_ids = [setting for setting in settings]
|
||||
missing_ids = [
|
||||
setting for setting in db_ids if setting not in setting_ids
|
||||
]
|
||||
|
|
@ -1222,8 +1222,8 @@ class Database:
|
|||
if value["type"] != db_setting.type:
|
||||
updates[Settings.type] = value["type"]
|
||||
|
||||
if value["multiple"] != db_setting.multiple:
|
||||
updates[Settings.multiple] = value["multiple"]
|
||||
if value.get("multiple") != db_setting.multiple:
|
||||
updates[Settings.multiple] = value.get("multiple")
|
||||
|
||||
if updates:
|
||||
session.query(Settings).filter(
|
||||
|
|
@ -1237,9 +1237,7 @@ class Database:
|
|||
.all()
|
||||
)
|
||||
db_values = [select.value for select in db_selects]
|
||||
select_values = [
|
||||
select["value"] for select in value.get("select", [])
|
||||
]
|
||||
select_values = value.get("select", [])
|
||||
missing_values = [
|
||||
select
|
||||
for select in db_values
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from copy import deepcopy
|
||||
from glob import glob
|
||||
from hashlib import sha256
|
||||
from io import BytesIO
|
||||
|
|
@ -174,7 +175,9 @@ def generate_external_plugins(
|
|||
|
||||
|
||||
def dict_to_frozenset(d):
|
||||
if isinstance(d, dict):
|
||||
if isinstance(d, list):
|
||||
return tuple(sorted(d))
|
||||
elif isinstance(d, dict):
|
||||
return frozenset((k, dict_to_frozenset(v)) for k, v in d.items())
|
||||
return d
|
||||
|
||||
|
|
@ -419,14 +422,20 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
tmp_external_plugins = []
|
||||
for external_plugin in external_plugins.copy():
|
||||
for external_plugin in deepcopy(external_plugins):
|
||||
external_plugin.pop("data", None)
|
||||
external_plugin.pop("checksum", None)
|
||||
external_plugin.pop("jobs", None)
|
||||
external_plugin.pop("method", None)
|
||||
tmp_external_plugins.append(external_plugin)
|
||||
|
||||
changes = {dict_to_frozenset(d) for d in tmp_external_plugins} != {
|
||||
dict_to_frozenset(d) for d in db_plugins
|
||||
tmp_db_plugins = []
|
||||
for db_plugin in db_plugins.copy():
|
||||
db_plugin.pop("method", None)
|
||||
tmp_db_plugins.append(db_plugin)
|
||||
|
||||
changes = {hash(dict_to_frozenset(d)) for d in tmp_external_plugins} != {
|
||||
hash(dict_to_frozenset(d)) for d in tmp_db_plugins
|
||||
}
|
||||
|
||||
if changes:
|
||||
|
|
|
|||
Loading…
Reference in a new issue