From 2ce89c2945b46680827e328c13e5f838790c7ce2 Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Sun, 23 Jun 2024 13:01:21 +0200 Subject: [PATCH] Fix removal of immutable/append-only files --- jlmkr.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jlmkr.py b/jlmkr.py index 262fab3..e745866 100755 --- a/jlmkr.py +++ b/jlmkr.py @@ -775,7 +775,12 @@ def cleanup(jail_path): # Should be fixed in Python 3.13 https://stackoverflow.com/a/70549000 def _onerror(func, path, exc_info): exc_type, exc_value, exc_traceback = exc_info - if not issubclass(exc_type, FileNotFoundError): + if issubclass(exc_type, PermissionError): + # Update the file permissions with the immutable and append-only bit cleared + subprocess.run(["chattr", "-i", "-a", path]) + # Reattempt the removal + func(path) + elif not issubclass(exc_type, FileNotFoundError): raise exc_value eprint(f"Cleaning up: {jail_path}.")