mirror of
https://github.com/frappe/bench.git
synced 2025-01-06 23:44:03 +00:00
fix: wrap tarfile with error handling
- ensure return to cwd after tarring
This commit is contained in:
parent
0e2e8b4da3
commit
30f301e3ff
16
bench/app.py
16
bench/app.py
@ -365,11 +365,19 @@ class App(AppMeta):
|
|||||||
click.secho(message)
|
click.secho(message)
|
||||||
|
|
||||||
self.prune_app_directory()
|
self.prune_app_directory()
|
||||||
|
|
||||||
|
success = False
|
||||||
os.chdir(app_path.parent)
|
os.chdir(app_path.parent)
|
||||||
with tarfile.open(cache_path, mode) as tar:
|
try:
|
||||||
tar.add(app_path.name)
|
with tarfile.open(cache_path, mode) as tar:
|
||||||
os.chdir(cwd)
|
tar.add(app_path.name)
|
||||||
return True
|
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):
|
def prune_app_directory(self):
|
||||||
app_path = self.get_app_path()
|
app_path = self.get_app_path()
|
||||||
|
Loading…
Reference in New Issue
Block a user