fix: Enhance removal process by adding database cleanup and improving error handling

This commit is contained in:
2026-05-27 12:52:15 +02:00
parent e1b8189ff8
commit a09e7add03
+18 -3
View File
@@ -329,10 +329,25 @@ class instace:
Output:
- bool if the removal works (True: removal worked; False: didnt work)
"""
if execute_script(_var, _cmd, "remove", clear_special(name)):
return True
else:
safe_name = clear_special(name)
# try to remove via management script
script_ok = execute_script(_var, _cmd, "remove", safe_name)
if not script_ok:
return False
# best-effort: remove the associated package entry from the database
client = None
try:
client, packages = _get_users_collection()
packages.delete_one({"client_name": name})
except Exception:
# don't fail the overall removal if DB cleanup fails
pass
finally:
if client:
client.close()
return True
def status(name: str) -> bool: