Permalink
Browse files

download bundle atomically

Reviewed By: javache

Differential Revision: D5697494

fbshipit-source-id: 9217194b609aabf3da23a092b3e5887925bb9bbc
  • Loading branch information...
bnham authored and facebook-github-bot committed Aug 30, 2017
1 parent c68bb6a commit d63cf13ce16d3a0d64f3296c39420397e2bd750b
Showing with 8 additions and 2 deletions.
  1. +8 −2 ReactAndroid/src/main/java/com/facebook/react/devsupport/BundleDownloader.java
@@ -172,15 +172,21 @@ private void processBundleResult(
return;
}
File tmpFile = new File(outputFile.getPath() + ".tmp");
Sink output = null;
try {
output = Okio.sink(outputFile);
output = Okio.sink(tmpFile);
body.readAll(output);
callback.onSuccess();
} finally {
if (output != null) {
output.close();
}
}
if (tmpFile.renameTo(outputFile)) {
callback.onSuccess();
} else {
throw new IOException("Couldn't rename " + tmpFile + " to " + outputFile);
}
}
}

0 comments on commit d63cf13

Please sign in to comment.