mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 17:30:38 +08:00
download bundle atomically
Reviewed By: javache Differential Revision: D5697494 fbshipit-source-id: 9217194b609aabf3da23a092b3e5887925bb9bbc
This commit is contained in:
committed by
Facebook Github Bot
parent
c68bb6a72c
commit
d63cf13ce1
@@ -172,15 +172,21 @@ public class BundleDownloader {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user