Merge "Fix multiple copies of read-only files in sbox" am: 85920c9389

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1660771

Change-Id: Id5fe4b0d8b4d276644458b4f1258893a002f1b8e
This commit is contained in:
Colin Cross
2021-04-01 01:33:17 +00:00
committed by Automerger Merge Worker

View File

@@ -387,6 +387,14 @@ func copyOneFile(from string, to string, executable bool) error {
}
defer in.Close()
// Remove the target before copying. In most cases the file won't exist, but if there are
// duplicate copy rules for a file and the source file was read-only the second copy could
// fail.
err = os.Remove(to)
if err != nil && !os.IsNotExist(err) {
return err
}
out, err := os.Create(to)
if err != nil {
return err