bitbake: utils: Use rm -rf in remove()
Whilst shutils.rmtree() is pythonic, its also slow. Its faster to use rm -rf which makes optimial use of the right syscalls. (Bitbake rev: 96088ebdec08e49ba9e8dbcac437bfcdc21f5983) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
5da2485717
commit
f7836b1299
|
@ -535,14 +535,17 @@ def remove(path, recurse=False):
|
||||||
"""Equivalent to rm -f or rm -rf"""
|
"""Equivalent to rm -f or rm -rf"""
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
import os, errno, shutil, glob
|
if recurse:
|
||||||
|
import subprocess
|
||||||
|
# shutil.rmtree(name) would be ideal but its too slow
|
||||||
|
subprocess.call("rm -rf %s" % path, shell=True)
|
||||||
|
return
|
||||||
|
import os, errno, glob
|
||||||
for name in glob.glob(path):
|
for name in glob.glob(path):
|
||||||
try:
|
try:
|
||||||
os.unlink(name)
|
os.unlink(name)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
if recurse and exc.errno == errno.EISDIR:
|
if exc.errno != errno.ENOENT:
|
||||||
shutil.rmtree(name)
|
|
||||||
elif exc.errno != errno.ENOENT:
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def prunedir(topdir):
|
def prunedir(topdir):
|
||||||
|
|
Loading…
Reference in New Issue