Snap for 7325276 from 3166f1a8bf81b62cf6865f9ea2cb04a39c696fd1 to sc-release
Change-Id: I82b0b027c2ea2524dd936ae960dd176675f395eb
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 @@
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 @@
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);
}