From 2dfc32dde930e6a37240f03a40bcdf4d6931d611 Mon Sep 17 00:00:00 2001 From: sago35 Date: Sat, 24 Apr 2021 11:12:04 +0900 Subject: [PATCH] builder: fixed a problem with multiple process build cases (ar) --- builder/buildcache.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/builder/buildcache.go b/builder/buildcache.go index b673de06e..3775b3ad3 100644 --- a/builder/buildcache.go +++ b/builder/buildcache.go @@ -84,7 +84,7 @@ func copyFile(src, dst string) error { return err } defer inf.Close() - outpath := dst + ".tmp" + outpath := src + ".tmp" outf, err := os.Create(outpath) if err != nil { return err @@ -101,5 +101,10 @@ func copyFile(src, dst string) error { return err } - return os.Rename(dst+".tmp", dst) + // Rename may fail if another process is trying to write to + // the same file. However, in this case, the failure is + // acceptable because the result of the other process can be + // used. + os.Rename(outpath, dst) + return nil }