2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-25 05:19:04 +00:00

fix: Delete folder if --no-backup is passed

This commit is contained in:
gavin 2022-05-19 13:09:18 +05:30
parent 69e14e512f
commit f7f7459c51
2 changed files with 13 additions and 8 deletions

View File

@ -179,13 +179,19 @@ class App(AppMeta):
) )
@step(title="Archiving App {repo}", success="App {repo} Archived") @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) 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) if no_backup:
archived_app_path = os.path.join(archived_path, archived_name) shutil.rmtree(active_app_path)
log(f"App moved from {active_app_path} to {archived_app_path}") log(f"App deleted from {active_app_path}")
shutil.move(active_app_path, archived_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") @step(title="Installing App {repo}", success="App {repo} Installed")
def install( def install(

View File

@ -312,8 +312,7 @@ class BenchApps(MutableSequence):
def remove(self, app: "App", no_backup: bool = False): def remove(self, app: "App", no_backup: bool = False):
app.uninstall() app.uninstall()
if not no_backup: app.remove(no_backup=no_backup)
app.remove()
super().remove(app.repo) super().remove(app.repo)
def append(self, app: "App"): def append(self, app: "App"):