|
@@ -11,6 +11,8 @@ from pathlib import Path
|
|
|
|
|
|
from _common import ENCODING, get_logger, add_common_params
|
|
|
import sys
|
|
|
+import os
|
|
|
+import stat
|
|
|
|
|
|
|
|
|
def prune_dir(unpack_root, prune_files):
|
|
@@ -25,6 +27,11 @@ def prune_dir(unpack_root, prune_files):
|
|
|
file_path = unpack_root / relative_file
|
|
|
try:
|
|
|
file_path.unlink()
|
|
|
+ # read-only files can't be deleted on Windows
|
|
|
+ # so remove the flag and try again.
|
|
|
+ except PermissionError:
|
|
|
+ os.chmod(file_path, stat.S_IWRITE)
|
|
|
+ file_path.unlink()
|
|
|
except FileNotFoundError:
|
|
|
unremovable_files.add(Path(relative_file).as_posix())
|
|
|
return unremovable_files
|