From f7f7459c51ad9b73d79d04e14d252de42289b44a Mon Sep 17 00:00:00 2001 From: gavin Date: Thu, 19 May 2022 13:09:18 +0530 Subject: [PATCH] fix: Delete folder if --no-backup is passed --- bench/app.py | 18 ++++++++++++------ bench/bench.py | 3 +-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bench/app.py b/bench/app.py index 5b3f05a7..4b527366 100755 --- a/bench/app.py +++ b/bench/app.py @@ -179,13 +179,19 @@ class App(AppMeta): ) @step(title="Archiving App {repo}", success="App {repo} Archived") - def remove(self): + def remove(self, no_backup: bool = False): active_app_path = os.path.join("apps", self.name) - archived_path = os.path.join("archived", "apps") - archived_name = get_available_folder_name(f"{self.repo}-{date.today()}", archived_path) - archived_app_path = os.path.join(archived_path, archived_name) - log(f"App moved from {active_app_path} to {archived_app_path}") - shutil.move(active_app_path, archived_app_path) + + if no_backup: + shutil.rmtree(active_app_path) + log(f"App deleted from {active_app_path}") + else: + archived_path = os.path.join("archived", "apps") + archived_name = get_available_folder_name(f"{self.repo}-{date.today()}", archived_path) + archived_app_path = os.path.join(archived_path, archived_name) + + shutil.move(active_app_path, archived_app_path) + log(f"App moved from {active_app_path} to {archived_app_path}") @step(title="Installing App {repo}", success="App {repo} Installed") def install( diff --git a/bench/bench.py b/bench/bench.py index 4aea84b3..66bcd099 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -312,8 +312,7 @@ class BenchApps(MutableSequence): def remove(self, app: "App", no_backup: bool = False): app.uninstall() - if not no_backup: - app.remove() + app.remove(no_backup=no_backup) super().remove(app.repo) def append(self, app: "App"):