mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-21 15:05:28 +00:00
Fix "rm_rf" in build.py on Windows
prebuilt/windows-x86_64/bin/libpython2.7.dll prebuilt/windows-x86_64/lib/python2.7/config/libpython2.7.dll.a These two files in NDK has read-only attribute on Windows, remove these files with Python will get "WindowsError: [Error 5] Access is denied". It will finally make "build.py ndk" unable to remove the "magisk" folder. This commit add a onerror callback for "shutil.rmtree" which clear the "read-only" attribute and retry.
This commit is contained in:
parent
82f8948fd4
commit
afe3c2bc1b
10
build.py
10
build.py
@ -11,6 +11,7 @@ import lzma
|
||||
import platform
|
||||
import urllib.request
|
||||
import os.path as op
|
||||
import stat
|
||||
from distutils.dir_util import copy_tree
|
||||
|
||||
|
||||
@ -96,9 +97,16 @@ def rm(file):
|
||||
raise
|
||||
|
||||
|
||||
def rm_on_error(func, path, _):
|
||||
# Remove a read-only file on Windows will get "WindowsError: [Error 5] Access is denied"
|
||||
# Clear the "read-only" and retry
|
||||
os.chmod(path, stat.S_IWRITE)
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def rm_rf(path):
|
||||
vprint(f'rm -rf {path}')
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
shutil.rmtree(path, ignore_errors=True, onerror=rm_on_error)
|
||||
|
||||
|
||||
def mkdir(path, mode=0o755):
|
||||
|
Loading…
Reference in New Issue
Block a user