react-native-update 7.4.0-beta.0 → 7.4.0
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.
|
@@ -70,7 +70,7 @@ public class UpdateModule extends ReactContextBaseJavaModule {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
@ReactMethod
|
|
73
|
-
public void
|
|
73
|
+
public void downloadFullUpdate(ReadableMap options, final Promise promise) {
|
|
74
74
|
String url = options.getString("updateUrl");
|
|
75
75
|
String hash = options.getString("hash");
|
|
76
76
|
updateContext.downloadFullUpdate(url, hash, new UpdateContext.DownloadFileListener() {
|
package/ios/RCTPushy/RCTPushy.m
CHANGED
|
@@ -224,7 +224,7 @@ RCT_EXPORT_METHOD(getLocalHashInfo:(NSString *)hash
|
|
|
224
224
|
resolve([defaults stringForKey:[keyHashInfo stringByAppendingString:hash]]);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
RCT_EXPORT_METHOD(
|
|
227
|
+
RCT_EXPORT_METHOD(downloadFullUpdate:(NSDictionary *)options
|
|
228
228
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
229
229
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
230
230
|
{
|
package/lib/main.js
CHANGED
|
@@ -95,7 +95,7 @@ export const cInfo = {
|
|
|
95
95
|
|
|
96
96
|
function assertRelease() {
|
|
97
97
|
if (__DEV__) {
|
|
98
|
-
throw new Error('react-native-update
|
|
98
|
+
throw new Error('react-native-update 只能在 RELEASE 版本中运行.');
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -209,6 +209,7 @@ export async function downloadUpdate(options, eventListeners) {
|
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
let succeeded = false;
|
|
212
213
|
if (options.diffUrl) {
|
|
213
214
|
logger('downloading diff');
|
|
214
215
|
try {
|
|
@@ -217,38 +218,45 @@ export async function downloadUpdate(options, eventListeners) {
|
|
|
217
218
|
hash: options.hash,
|
|
218
219
|
originHash: currentVersion,
|
|
219
220
|
});
|
|
221
|
+
succeeded = true;
|
|
220
222
|
} catch (e) {
|
|
221
223
|
logger(`diff error: ${e.message}, try pdiff`);
|
|
222
|
-
try {
|
|
223
|
-
await Pushy.downloadPatchFromPackage({
|
|
224
|
-
updateUrl: options.pdiffUrl,
|
|
225
|
-
hash: options.hash,
|
|
226
|
-
});
|
|
227
|
-
} catch (e) {
|
|
228
|
-
progressHandler && progressHandler.remove();
|
|
229
|
-
report(options.hash, 'error');
|
|
230
|
-
throw e;
|
|
231
|
-
}
|
|
232
224
|
}
|
|
233
|
-
}
|
|
225
|
+
}
|
|
226
|
+
if (!succeeded && options.pdiffUrl) {
|
|
234
227
|
logger('downloading pdiff');
|
|
235
228
|
try {
|
|
236
229
|
await Pushy.downloadPatchFromPackage({
|
|
237
230
|
updateUrl: options.pdiffUrl,
|
|
238
231
|
hash: options.hash,
|
|
239
232
|
});
|
|
233
|
+
succeeded = true;
|
|
240
234
|
} catch (e) {
|
|
241
|
-
|
|
242
|
-
report(options.hash, 'error');
|
|
243
|
-
throw e;
|
|
235
|
+
logger(`pdiff error: ${e.message}, try full patch`);
|
|
244
236
|
}
|
|
245
237
|
}
|
|
238
|
+
if (!succeeded && options.updateUrl) {
|
|
239
|
+
logger('downloading full patch');
|
|
240
|
+
try {
|
|
241
|
+
await Pushy.downloadFullUpdate({
|
|
242
|
+
updateUrl: options.updateUrl,
|
|
243
|
+
hash: options.hash,
|
|
244
|
+
});
|
|
245
|
+
succeeded = true;
|
|
246
|
+
} catch (e) {
|
|
247
|
+
logger(`full patch error: ${e.message}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
progressHandler && progressHandler.remove();
|
|
251
|
+
if (!succeeded) {
|
|
252
|
+
report(options.hash, 'error');
|
|
253
|
+
throw new Error('all update attempts failed');
|
|
254
|
+
}
|
|
246
255
|
setLocalHashInfo(options.hash, {
|
|
247
256
|
name: options.name,
|
|
248
257
|
description: options.description,
|
|
249
258
|
metaInfo: options.metaInfo,
|
|
250
259
|
});
|
|
251
|
-
progressHandler && progressHandler.remove();
|
|
252
260
|
downloadedHash = options.hash;
|
|
253
261
|
return options.hash;
|
|
254
262
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update",
|
|
3
|
-
"version": "7.4.0
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "react-native hot update",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"nanoid": "^3.
|
|
31
|
+
"nanoid": "^3.3.3"
|
|
32
32
|
}
|
|
33
33
|
}
|