chiark / gitweb /
common: use python instead of calling out to 'rm'
authorMarcus Hoffmann <bubuiic@aol.com>
Sat, 25 Nov 2017 02:05:59 +0000 (03:05 +0100)
committerMarcus Hoffmann <bubuiic@aol.com>
Sat, 25 Nov 2017 12:49:33 +0000 (13:49 +0100)
Be platform agnostic by not calling other utilities.

fdroidserver/common.py

index 98bc2cb2aacd8e3601b9aba2d146768bfa2fcab8..369292cc5a8216cc8fcae9dbf997bcdd3e3692fa 100644 (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")