diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-30 01:06:55 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-30 01:06:55 +0000 |
commit | 49f72ee3bfc848561912d4ae615c09c837aa11a6 (patch) | |
tree | c17317e718ada6f5cc43e86d859522c5bcda6fd5 | |
parent | 41c3a837308251c0b1c764d4aed02a3922f7718c (diff) | |
parent | 3166f1a8bf81b62cf6865f9ea2cb04a39c696fd1 (diff) | |
download | vogar-android12-d1-release.tar.gz |
Snap for 7325096 from 3166f1a8bf81b62cf6865f9ea2cb04a39c696fd1 to sc-d1-releaseandroid-12.0.0_r7android-12.0.0_r6android-12.0.0_r5android-12.0.0_r4android-12.0.0_r15android-12.0.0_r14android-12.0.0_r13android-12.0.0_r12android12-d1-s6-releaseandroid12-d1-s5-releaseandroid12-d1-s4-releaseandroid12-d1-s3-releaseandroid12-d1-s2-releaseandroid12-d1-s1-releaseandroid12-d1-release
Change-Id: I41fc6ed2443b155d7683520803a537d601b96db4
-rw-r--r-- | OWNERS | 6 | ||||
-rw-r--r-- | src/vogar/HostFileCache.java | 6 |
2 files changed, 8 insertions, 4 deletions
@@ -1,3 +1,5 @@ -rpl@google.com -paulduffin@google.com android-libcore-team+review@google.com +dsrbecky@google.com +ngeoffray@google.com +paulduffin@google.com +rpl@google.com diff --git a/src/vogar/HostFileCache.java b/src/vogar/HostFileCache.java index a2282f3..9232902 100644 --- a/src/vogar/HostFileCache.java +++ b/src/vogar/HostFileCache.java @@ -17,6 +17,7 @@ package vogar; import java.io.File; +import java.lang.ProcessHandle; import java.util.List; import vogar.commands.Command; import vogar.commands.Mkdir; @@ -44,7 +45,8 @@ public class HostFileCache implements FileCache { private void mv(File source, File destination) { List<String> rawResult = new Command.Builder(log).args("mv", source, destination).execute(); // A successful move returns no results. - if (!rawResult.isEmpty()) { + // Note that other process might have moved the file to the destination at the same time. + if (!rawResult.isEmpty() && !destination.exists()) { throw new RuntimeException("Couldn't move " + source + " to " + destination + ": " + rawResult.get(0)); } @@ -60,7 +62,7 @@ public class HostFileCache implements FileCache { mkdir.mkdirs(CACHE_ROOT); // Copy it onto the same file system first, then atomically move it into place. // That way, if we fail, we don't leave anything dangerous lying around. - File temporary = new File(cachedFile + ".tmp"); + File temporary = new File(cachedFile + ".tmp" + String.valueOf(ProcessHandle.current().pid())); cp(source, temporary); mv(temporary, cachedFile); } |