Skip to content

Commit

Permalink
fix: Delete folder if --no-backup is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed May 19, 2022
1 parent 69e14e5 commit f7f7459
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 12 additions & 6 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ def get(self):
)

@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(
Expand Down
3 changes: 1 addition & 2 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ def add(self, app: "App"):

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"):
Expand Down

0 comments on commit f7f7459

Please sign in to comment.