Use os.renames() in remove() to auto-create subdirectories.

Bug: 1415507
Change-Id: Ie52123dc0844639116b55bc7f6a2734aaf7df33e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4378417
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
This commit is contained in:
Joanna Wang
2023-03-28 20:25:55 +00:00
committed by LUCI CQ
parent 857600b9ef
commit 489304d949

View File

@@ -366,8 +366,8 @@ def remove(target, cleanup_dir):
allfiles = os.listdir(target)
for f in allfiles:
target_path = os.path.join(target, f)
dst_path = os.path.join(destination, f)
os.rename(target_path, dst_path)
dst_path = os.path.join(dest, f)
os.renames(target_path, dst_path)
except Exception as e:
print('Error renaming %s to %s: %s' % (target, dest, str(e)))
raise