Skip to content

Commit

Permalink
chore: Update Database.py to set custom_configs_changed flag and last…
Browse files Browse the repository at this point in the history
…_custom_configs_change timestamp when saving config and services were removed to avoid deleted custom configs still hanging
  • Loading branch information
TheophileDiot committed Jun 18, 2024
1 parent 774f239 commit 9b2805a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,9 @@ def save_config(self, config: Dict[str, Any], method: str, changed: Optional[boo
session.query(Services_settings).filter(Services_settings.service_id.in_(missing_ids)).delete()
session.query(Custom_configs).filter(Custom_configs.service_id.in_(missing_ids)).delete()
session.query(Jobs_cache).filter(Jobs_cache.service_id.in_(missing_ids)).delete()
session.query(Metadata).filter_by(id=1).update(
{Metadata.custom_configs_changed: True, Metadata.last_custom_configs_change: datetime.now()}
)
changed_services = True

drafts = {service for service in services if config.pop(f"{service}_IS_DRAFT", "no") == "yes"}
Expand Down
8 changes: 0 additions & 8 deletions src/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,6 @@ def manage_bunkerweb(method: str, *args, operation: str = "reloads", is_draft: b
operation, error = app.config["CONFIG"].edit_service(args[1], args[0], check_changes=(was_draft != is_draft or not is_draft), is_draft=is_draft)
elif operation == "delete":
operation, error = app.config["CONFIG"].delete_service(args[2], check_changes=(was_draft != is_draft or not is_draft))

if not error:
if was_draft != is_draft or not is_draft:
# update changes in db
ret = app.config["DB"].checked_changes(["config", "custom_configs"], value=True)
if ret:
app.logger.error(f"Couldn't set the changes to checked in the database: {ret}")
ui_data["TO_FLASH"].append({"content": f"An error occurred when setting the changes to checked in the database : {ret}", "type": "error"})
elif method == "global_config":
operation, error = app.config["CONFIG"].edit_global_conf(args[0])

Expand Down

0 comments on commit 9b2805a

Please sign in to comment.