[ios] Fix build/config/ios/hardlink.py when output exists

shutil.rmtree fails if asked to delete a single file, so change
build/config/ios/hardlink.py to use os.unlink/shutil.rmtree based
on the output type (directory, file, symlink, ...).

Bug: none
Change-Id: I861c215e91b455e5b24f8159e162f21644a4bd47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390183
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803861}
GitOrigin-RevId: af8f4f5d6065be3c60bb5a1b3ccefb94bea6493f
This commit is contained in:
Sylvain Defresne 2020-09-02 15:06:58 +00:00 коммит произвёл Copybara-Service
Родитель 5bc1cb373f
Коммит c8b72be369
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -46,8 +46,10 @@ def CreateHardlink(target, output):
If output already exists, it is first removed. In all cases, the
parent directory containing output is created.
"""
if os.path.exists(output):
if os.path.isdir(output):
shutil.rmtree(output)
elif os.path.exists(output):
os.unlink(output)
parent_dir = os.path.dirname(os.path.abspath(output))
if not os.path.isdir(parent_dir):