From: Marcus Hoffmann Date: Sat, 25 Nov 2017 02:05:59 +0000 (+0100) Subject: common: use python instead of calling out to 'rm' X-Git-Tag: 0.9~10^2 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c790f43bf3987aac7e5afe725bdd6ab58adf66cc;p=fdroidserver.git common: use python instead of calling out to 'rm' Be platform agnostic by not calling other utilities. --- diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 98bc2cb2..369292cc 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1583,10 +1583,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver= dest = os.path.join(build_dir, part) logging.info("Removing {0}".format(part)) if os.path.lexists(dest): - if os.path.islink(dest): - FDroidPopen(['unlink', dest], output=False) + # rmtree can only handle directories that are not symlinks, so catch anything else + if not os.path.isdir(dest) or os.path.islink(dest): + os.remove(dest) else: - FDroidPopen(['rm', '-rf', dest], output=False) + shutil.rmtree(dest) else: logging.info("...but it didn't exist")