Skip to content

Commit

Permalink
Handle errors gracefully on purge (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoBrandao authored Feb 13, 2024
1 parent 85594d3 commit d76b216
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions src/fprime/fbuild/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,27 @@ def run_fbuild_cli(
print(
f"[INFO] {parsed.command.title()} build directory at: {purge_build.build_dir}"
)
if parsed.force or confirm("Purge this directory?"):
purge_build.purge()
install_dir = purge_build.install_dest_exists()
if (
purge_build.build_type != BuildType.BUILD_CUSTOM
and install_dir
and install_dir.exists()
):
try:
if parsed.force or confirm("Purge this directory?"):
purge_build.purge()
install_dir = purge_build.install_dest_exists()
if (
purge_build.build_type != BuildType.BUILD_CUSTOM
and install_dir
and install_dir.exists()
):
print(
f"[INFO] {parsed.command.title()} install directory at: {install_dir}"
)
if parsed.force or confirm(
f"Purge installation directory at {install_dir} ?"
):
purge_build.purge_install()
except PermissionError as e:
print(
f"[INFO] {parsed.command.title()} install directory at: {install_dir}"
f"Error: Permission denied while purging {purge_build.build_dir}: {e}"
)
if parsed.force or confirm(
f"Purge installation directory at {install_dir} ?"
):
purge_build.purge_install()

else:
target = get_target(parsed)
option_args = {
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/fbuild/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def purge(build_dir):
:param build_dir: build dir specified to purge
"""
shutil.rmtree(build_dir, ignore_errors=True)
shutil.rmtree(build_dir)

def _read_values_from_cache(self, keys, build_dir):
"""
Expand Down

0 comments on commit d76b216

Please sign in to comment.