1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-03 17:50:11 +02:00

common: use python instead of calling out to 'rm'

Be platform agnostic by not calling other utilities.
This commit is contained in:
Marcus Hoffmann 2017-11-25 03:05:59 +01:00
parent 4b51cc273a
commit c790f43bf3

View File

@ -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")