react-native-update 10.38.0-beta.0 → 10.38.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -191,6 +191,39 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
191
191
  return fout.toByteArray();
192
192
  }
193
193
 
194
+ private void appendManifestEntries(
195
+ JSONObject manifest,
196
+ ArrayList<String> copyFroms,
197
+ ArrayList<String> copyTos,
198
+ ArrayList<String> deletes,
199
+ HashMap<String, String> copiesMap
200
+ ) throws JSONException {
201
+ JSONObject copies = manifest.optJSONObject("copies");
202
+ if (copies != null) {
203
+ Iterator<?> keys = copies.keys();
204
+ while (keys.hasNext()) {
205
+ String to = (String) keys.next();
206
+ String from = copies.getString(to);
207
+ if (from.isEmpty()) {
208
+ from = to;
209
+ }
210
+ copyFroms.add(from);
211
+ copyTos.add(to);
212
+ if (copiesMap != null) {
213
+ copiesMap.put(to, from);
214
+ }
215
+ }
216
+ }
217
+
218
+ JSONObject deleteMap = manifest.optJSONObject("deletes");
219
+ if (deleteMap != null) {
220
+ Iterator<?> deleteKeys = deleteMap.keys();
221
+ while (deleteKeys.hasNext()) {
222
+ deletes.add((String) deleteKeys.next());
223
+ }
224
+ }
225
+ }
226
+
194
227
  private void copyBundledAssetToFile(String assetName, File destination) throws IOException {
195
228
  InputStream in = context.getAssets().open(assetName);
196
229
  FileOutputStream fout = new FileOutputStream(destination);
@@ -480,25 +513,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
480
513
  byte[] bytes = readBytes(zipFile.getInputStream(ze));
481
514
  String json = new String(bytes, "UTF-8");
482
515
  JSONObject obj = (JSONObject)new JSONTokener(json).nextValue();
483
-
484
- JSONObject copies = obj.getJSONObject("copies");
485
- Iterator<?> keys = copies.keys();
486
- while( keys.hasNext() ) {
487
- String to = (String)keys.next();
488
- String from = copies.getString(to);
489
- if (from.isEmpty()) {
490
- from = to;
491
- }
492
- copyFroms.add(from);
493
- copyTos.add(to);
494
- // 保存 copies 映射关系(to -> from)
495
- copiesMap.put(to, from);
496
- }
497
- JSONObject blackList = obj.getJSONObject("deletes");
498
- Iterator<?> deleteKeys = blackList.keys();
499
- while (deleteKeys.hasNext()) {
500
- deletes.add((String)deleteKeys.next());
501
- }
516
+ appendManifestEntries(obj, copyFroms, copyTos, deletes, copiesMap);
502
517
  continue;
503
518
  }
504
519
  zipFile.unzipToPath(ze, param.unzipDirectory);
@@ -579,23 +594,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
579
594
  byte[] bytes = readBytes(zipFile.getInputStream(ze));
580
595
  String json = new String(bytes, "UTF-8");
581
596
  JSONObject obj = (JSONObject)new JSONTokener(json).nextValue();
582
-
583
- JSONObject copies = obj.getJSONObject("copies");
584
- Iterator<?> keys = copies.keys();
585
- while( keys.hasNext() ) {
586
- String to = (String)keys.next();
587
- String from = copies.getString(to);
588
- if (from.isEmpty()) {
589
- from = to;
590
- }
591
- copyFroms.add(from);
592
- copyTos.add(to);
593
- }
594
- JSONObject blackList = obj.getJSONObject("deletes");
595
- Iterator<?> deleteKeys = blackList.keys();
596
- while (deleteKeys.hasNext()) {
597
- deletes.add((String)deleteKeys.next());
598
- }
597
+ appendManifestEntries(obj, copyFroms, copyTos, deletes, null);
599
598
  continue;
600
599
  }
601
600
  zipFile.unzipToPath(ze, param.unzipDirectory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.38.0-beta.0",
3
+ "version": "10.38.0-beta.1",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {