Skip to content

Commit

Permalink
fix: Handle collisions while moving apps
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Nov 13, 2021
1 parent 17edb47 commit 3709682
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,22 @@ def get(self):
)

def remove(self):
shutil.move(
os.path.join("apps", self.repo), os.path.join("archived", "apps", self.repo),
)
import datetime
from bench.utils import log

def get_archived_app_name():
dt = f"{self.repo}-{datetime.date.today()}"
if os.path.exists(os.path.join("archived", "apps", dt)):
for num in range(1, 100):
dt = f"{dt}_{num}"
if not os.path.exists(os.path.join("archived", "apps", dt)):
return dt
return dt

src = os.path.join("apps", self.repo)
dst = os.path.join("archived", "apps", get_archived_app_name())
log(f"App moved from {src} to {dst}")
shutil.move(src, dst)

def install(self, skip_assets=False, verbose=False):
from bench.utils.app import get_app_name
Expand Down Expand Up @@ -291,6 +304,7 @@ def get_app(

app.get()
app.install(verbose=verbose, skip_assets=skip_assets)
bench.apps.sync()


def new_app(app, bench_path="."):
Expand Down

0 comments on commit 3709682

Please sign in to comment.