Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ private void processBundle(
File tmpFile = new File(outputFile.getPath() + ".tmp");

boolean bundleWritten;
boolean pushBundleNameToContainer = false;
NativeDeltaClient nativeDeltaClient = null;

if (BundleDeltaClient.isDeltaUrl(url)) {
Expand All @@ -507,17 +508,22 @@ private void processBundle(
Pair<Boolean, NativeDeltaClient> result = deltaClient.processDelta(headers, body, tmpFile);
bundleWritten = result.first;
nativeDeltaClient = result.second;
// Always push bundle name, regardless if it was written or not.
// If `bundleWritten` is `false` it means that the previously stored
// bundle is still valid, so we can safely add to `DevBundlesContainer`.
pushBundleNameToContainer = true;
} else {
mBundleDeltaClient = null;
bundleWritten = storePlainJSInFile(body, tmpFile);
pushBundleNameToContainer = bundleWritten;
}

if (bundleWritten) {
String bundleName = getBundleNameFromURL(url); // fallback
if (pushBundleNameToContainer && mDevBundlesContainer != null) {
String bundleName = getBundleNameFromURL(url);
mDevBundlesContainer.pushBundle(bundleName, url, outputFile.getPath());
}

if(mDevBundlesContainer != null) {
mDevBundlesContainer.pushBundle(bundleName, url, outputFile.getPath());
}
if (bundleWritten) {
if (!tmpFile.renameTo(outputFile)) {
throw new IOException("Couldn't rename " + tmpFile + " to " + outputFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String getFileURLByName(String name) {
public String getNameBySourceURL(String sourceURL) {
for (String key : bundleNameMapping.keySet()) {
BundleURLs tmp = bundleNameMapping.get(key);
if(tmp.sourceURL.equals(sourceURL)) {
if(tmp.sourceURL.equals(sourceURL.split("\\?")[0])) {
return key;
}
}
Expand All @@ -102,7 +102,7 @@ public String getNameByFileURL(String fileURL) {
public String getFileURLBySourceURL(String sourceURL) {
for (String key : bundleNameMapping.keySet()) {
BundleURLs tmp = bundleNameMapping.get(key);
if(tmp.sourceURL.equals(sourceURL)) {
if(tmp.sourceURL.startsWith(sourceURL.split("\\?")[0])) {
return tmp.fileURL;
}
}
Expand Down Expand Up @@ -136,4 +136,4 @@ public DevBundlesContainer(JSONObject json) {
FLog.e(ReactConstants.TAG, "DevBundlesContainer is unable to create from JSON");
}
}
}
}