copy_ex.py: allow overwriting non-writable files
Since shutil.copy() fails when it cannot open(2) O_WRONLY the destination, introduce an additional step: for a destination that is a file with different contents, delete the destination before copying. Back story: I noticed that in my tree quite a few files were not writeable. It was probably a consequence of a past bug, not sure which one. I was running: shell> build/android/gradle/generate_gradle.py --output-directory out/Debug This caused 'permission denied' from shutil.copy() when it attempted to open the file for writing. One way to reproduce it right now is: shell> cd out/Debug shell> touch obj/third_party/netty4/netty_all_java__process_prebuilt-filtered.jar shell> chmod u-w lib.java/third_party/netty4/netty-all-4.1.9.Final.jar shell> build/android/gradle/generate_gradle.py --output-directory out/Debug BUG=None Change-Id: Ifaa16d52bb2c0e6af362401fc635a3e21f3d7214 Reviewed-on: https://chromium-review.googlesource.com/1146923Reviewed-by:John Budorick <jbudorick@google.com> Reviewed-by:
John Budorick <jbudorick@chromium.org> Commit-Queue: Egor Pasko <pasko@chromium.org> Cr-Commit-Position: refs/heads/master@{#577253}
Showing
Please register or sign in to comment