Merge "Add vogar OWNERS"
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);
     }