Commit 1906f405 authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

gclient: When deleting untracked files, gracefully handle symlinks that point to dirs.

eg: https://logs.chromium.org/logs/chrome/buildbucket/cr-buildbucket.appspot.com/8898770399362199536/+/steps/bot_update/0/stdout

bot_update ends up clobbering the checkout in that build due to:
"Error: 161> Called rmtree(/b/s/w/ir/cache/builder/src/......) in non-directory"

That's because we're trying to rmtree a file. This will instead unlink
it.

Bug: 991276
Change-Id: Icffa18c27ddbaced20fb3410a91ca8fcc849d5e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1877727Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
parent 3671a6a2
......@@ -218,7 +218,7 @@ def safe_rename(old, new):
def rm_file_or_tree(path):
if os.path.isfile(path):
if os.path.isfile(path) or os.path.islink(path):
os.remove(path)
else:
rmtree(path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment