aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-04-30 01:06:55 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-04-30 01:06:55 +0000
commit49f72ee3bfc848561912d4ae615c09c837aa11a6 (patch)
treec17317e718ada6f5cc43e86d859522c5bcda6fd5
parent41c3a837308251c0b1c764d4aed02a3922f7718c (diff)
parent3166f1a8bf81b62cf6865f9ea2cb04a39c696fd1 (diff)
downloadvogar-android12-d1-release.tar.gz
Change-Id: I41fc6ed2443b155d7683520803a537d601b96db4
-rw-r--r--OWNERS6
-rw-r--r--src/vogar/HostFileCache.java6
2 files changed, 8 insertions, 4 deletions
diff --git a/OWNERS b/OWNERS
index ef63cea..2b36b97 100644
--- a/OWNERS
+++ b/OWNERS
@@ -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);
}