Skip to content

Commit

Permalink
[FIX] database_cleanup: unused code + wrong modules clean
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelZilli authored and jjscarafia committed Oct 10, 2023
1 parent b46c34f commit 923956b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions database_cleanup/models/purge_modules.py
Expand Up @@ -50,9 +50,11 @@ def purge(self):
if not modules:
return True
self.logger.info("Purging modules %s", ", ".join(module_names))
modules.filtered(
lambda x: x.state not in ("uninstallable", "uninstalled")
).button_immediate_uninstall()
installed = modules.filtered(lambda x: x.state in ("installed", "to upgrade"))
((modules - installed) + (modules - installed).downstream_dependencies()).write(
{"state": "to remove"}
)
installed.button_immediate_uninstall()
modules.env.invalidate_all()
modules.unlink()
return self.write({"purged": True})
Expand All @@ -72,13 +74,6 @@ def find(self):
):
if get_module_path(module.name, display_warning=False):
continue
if module.state == "uninstalled":
self.env["cleanup.purge.line.module"].create(
{
"name": module.name,
}
)
continue
res.append((0, 0, {"name": module.name}))

if not res:
Expand Down

0 comments on commit 923956b

Please sign in to comment.