Skip to content

Commit

Permalink
Randomize the Android downloaded bundle filename
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesreggio committed Oct 11, 2017
1 parent 78d5705 commit 2bc5d3e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class DevSupportManagerImpl implements

private static final int JAVA_ERROR_COOKIE = -1;
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
private static final String JS_BUNDLE_FILE_FORMAT = "ReactNativeDevBundle.%d.js";
private static enum ErrorType {
JS,
NATIVE
Expand Down Expand Up @@ -229,11 +229,15 @@ public void onReceive(Context context, Intent intent) {
};

// We store JS bundle loaded from dev server in a single destination in app's data dir.
// (We randomize the name in the event that there are multiple JS bridges running.)
// In case when someone schedule 2 subsequent reloads it may happen that JS thread will
// start reading first reload output while the second reload starts writing to the same
// file. As this should only be the case in dev mode we leave it as it is.
// TODO(6418010): Fix readers-writers problem in debug reload from HTTP server
mJSBundleTempFile = new File(applicationContext.getFilesDir(), JS_BUNDLE_FILE_NAME);
mJSBundleTempFile = new File(
applicationContext.getFilesDir(),
String.format(JS_BUNDLE_FILE_FORMAT, (int)(Math.random() * 1000000))
);

mDefaultNativeModuleCallExceptionHandler = new DefaultNativeModuleCallExceptionHandler();

Expand Down

0 comments on commit 2bc5d3e

Please sign in to comment.