2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-04 22:55:25 +00:00

fix: wrap tarfile with error handling

- ensure return to cwd after tarring
This commit is contained in:
18alantom 2024-01-18 18:06:08 +05:30
parent 0e2e8b4da3
commit 30f301e3ff

View File

@ -365,11 +365,19 @@ class App(AppMeta):
click.secho(message)
self.prune_app_directory()
success = False
os.chdir(app_path.parent)
with tarfile.open(cache_path, mode) as tar:
tar.add(app_path.name)
os.chdir(cwd)
return True
try:
with tarfile.open(cache_path, mode) as tar:
tar.add(app_path.name)
success = True
except Exception:
log(f"Failed to cache {app_path}", level=3)
success = False
finally:
os.chdir(cwd)
return success
def prune_app_directory(self):
app_path = self.get_app_path()