react-native-update 10.25.2 → 10.25.4
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.
|
@@ -49,7 +49,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
49
49
|
|
|
50
50
|
private void removeDirectory(File file) throws IOException {
|
|
51
51
|
if (UpdateContext.DEBUG) {
|
|
52
|
-
Log.d("
|
|
52
|
+
Log.d("react-native-update", "Removing " + file);
|
|
53
53
|
}
|
|
54
54
|
if (file.isDirectory()) {
|
|
55
55
|
File[] files = file.listFiles();
|
|
@@ -88,7 +88,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
88
88
|
BufferedSink sink = Okio.buffer(Okio.sink(writePath));
|
|
89
89
|
|
|
90
90
|
if (UpdateContext.DEBUG) {
|
|
91
|
-
Log.d("
|
|
91
|
+
Log.d("react-native-update", "Downloading " + url);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
long bytesRead = 0;
|
|
@@ -98,7 +98,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
98
98
|
received += bytesRead;
|
|
99
99
|
sink.emit();
|
|
100
100
|
if (UpdateContext.DEBUG) {
|
|
101
|
-
Log.d("
|
|
101
|
+
Log.d("react-native-update", "Progress " + received + "/" + contentLength);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
int percentage = (int)(received * 100.0 / contentLength + 0.5);
|
|
@@ -115,7 +115,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
115
115
|
sink.close();
|
|
116
116
|
|
|
117
117
|
if (UpdateContext.DEBUG) {
|
|
118
|
-
Log.d("
|
|
118
|
+
Log.d("react-native-update", "Download finished");
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -244,7 +244,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
if (UpdateContext.DEBUG) {
|
|
247
|
-
Log.d("
|
|
247
|
+
Log.d("react-native-update", "Unzip finished");
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -260,7 +260,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
260
260
|
File lastTarget = null;
|
|
261
261
|
for (File target: targets) {
|
|
262
262
|
if (UpdateContext.DEBUG) {
|
|
263
|
-
Log.d("
|
|
263
|
+
Log.d("react-native-update", "Copying from resource " + fn + " to " + target);
|
|
264
264
|
}
|
|
265
265
|
if (lastTarget != null) {
|
|
266
266
|
copyFile(lastTarget, target);
|
|
@@ -352,7 +352,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
352
352
|
copyFromResource(copyList);
|
|
353
353
|
|
|
354
354
|
if (UpdateContext.DEBUG) {
|
|
355
|
-
Log.d("
|
|
355
|
+
Log.d("react-native-update", "Unzip finished");
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
}
|
|
@@ -418,12 +418,12 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
418
418
|
throw new Error("bundle patch not found");
|
|
419
419
|
}
|
|
420
420
|
if (UpdateContext.DEBUG) {
|
|
421
|
-
Log.d("
|
|
421
|
+
Log.d("react-native-update", "Unzip finished");
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
private void doCleanUp(DownloadTaskParams param) throws IOException {
|
|
425
425
|
if (UpdateContext.DEBUG) {
|
|
426
|
-
Log.d("
|
|
426
|
+
Log.d("react-native-update", "Start cleaning up");
|
|
427
427
|
}
|
|
428
428
|
File root = param.unzipDirectory;
|
|
429
429
|
for (File sub : root.listFiles()) {
|
|
@@ -499,7 +499,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
499
499
|
default:
|
|
500
500
|
break;
|
|
501
501
|
}
|
|
502
|
-
Log.e("
|
|
502
|
+
Log.e("react-native-update", "download task failed", e);
|
|
503
503
|
|
|
504
504
|
if (params[0].listener != null) {
|
|
505
505
|
params[0].listener.onDownloadFailed(e);
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -82,13 +82,13 @@ export class Pushy {
|
|
|
82
82
|
};
|
|
83
83
|
})();
|
|
84
84
|
|
|
85
|
-
constructor(options: ClientOptions) {
|
|
85
|
+
constructor(options: ClientOptions, clientType?: 'Pushy' | 'Cresc') {
|
|
86
86
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
87
87
|
if (!options.appKey) {
|
|
88
88
|
throw new Error('appKey is required');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
this.clientType =
|
|
91
|
+
this.clientType = clientType || 'Pushy';
|
|
92
92
|
this.options.server = SERVER_PRESETS[this.clientType];
|
|
93
93
|
this.setOptions(options);
|
|
94
94
|
if (isRolledBack) {
|
|
@@ -226,10 +226,11 @@ export class Pushy {
|
|
|
226
226
|
// @ts-ignore
|
|
227
227
|
delete fetchBody.buildTime;
|
|
228
228
|
}
|
|
229
|
+
const stringifyBody = JSON.stringify(fetchBody);
|
|
229
230
|
// harmony fetch body is not string
|
|
230
231
|
let body: any = fetchBody;
|
|
231
232
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
232
|
-
body =
|
|
233
|
+
body = stringifyBody;
|
|
233
234
|
}
|
|
234
235
|
const fetchPayload = {
|
|
235
236
|
method: 'POST',
|
|
@@ -243,13 +244,13 @@ export class Pushy {
|
|
|
243
244
|
try {
|
|
244
245
|
this.report({
|
|
245
246
|
type: 'checking',
|
|
246
|
-
message: this.options.appKey + ': ' +
|
|
247
|
+
message: this.options.appKey + ': ' + stringifyBody,
|
|
247
248
|
});
|
|
248
249
|
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
|
249
250
|
} catch (e: any) {
|
|
250
251
|
this.report({
|
|
251
252
|
type: 'errorChecking',
|
|
252
|
-
message:
|
|
253
|
+
message: `Can not connect to update server: ${e.message}. Trying backup endpoints.`,
|
|
253
254
|
});
|
|
254
255
|
const backupEndpoints = await this.getBackupEndpoints();
|
|
255
256
|
if (backupEndpoints) {
|
|
@@ -361,6 +362,7 @@ export class Pushy {
|
|
|
361
362
|
let succeeded = '';
|
|
362
363
|
this.report({ type: 'downloading' });
|
|
363
364
|
let lastError: any;
|
|
365
|
+
let errorMessages: string[] = [];
|
|
364
366
|
const diffUrl = await testUrls(joinUrls(paths, diff));
|
|
365
367
|
if (diffUrl) {
|
|
366
368
|
log('downloading diff');
|
|
@@ -372,11 +374,13 @@ export class Pushy {
|
|
|
372
374
|
});
|
|
373
375
|
succeeded = 'diff';
|
|
374
376
|
} catch (e: any) {
|
|
375
|
-
|
|
377
|
+
const errorMessage = `diff error: ${e.message}`;
|
|
378
|
+
errorMessages.push(errorMessage);
|
|
379
|
+
lastError = new Error(errorMessage);
|
|
376
380
|
if (__DEV__) {
|
|
377
381
|
succeeded = 'diff';
|
|
378
382
|
} else {
|
|
379
|
-
log(
|
|
383
|
+
log(errorMessage);
|
|
380
384
|
}
|
|
381
385
|
}
|
|
382
386
|
}
|
|
@@ -390,11 +394,13 @@ export class Pushy {
|
|
|
390
394
|
});
|
|
391
395
|
succeeded = 'pdiff';
|
|
392
396
|
} catch (e: any) {
|
|
393
|
-
|
|
397
|
+
const errorMessage = `pdiff error: ${e.message}`;
|
|
398
|
+
errorMessages.push(errorMessage);
|
|
399
|
+
lastError = new Error(errorMessage);
|
|
394
400
|
if (__DEV__) {
|
|
395
401
|
succeeded = 'pdiff';
|
|
396
402
|
} else {
|
|
397
|
-
log(
|
|
403
|
+
log(errorMessage);
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
}
|
|
@@ -408,11 +414,13 @@ export class Pushy {
|
|
|
408
414
|
});
|
|
409
415
|
succeeded = 'full';
|
|
410
416
|
} catch (e: any) {
|
|
411
|
-
|
|
417
|
+
const errorMessage = `full patch error: ${e.message}`;
|
|
418
|
+
errorMessages.push(errorMessage);
|
|
419
|
+
lastError = new Error(errorMessage);
|
|
412
420
|
if (__DEV__) {
|
|
413
421
|
succeeded = 'full';
|
|
414
422
|
} else {
|
|
415
|
-
log(
|
|
423
|
+
log(errorMessage);
|
|
416
424
|
}
|
|
417
425
|
}
|
|
418
426
|
}
|
|
@@ -427,6 +435,7 @@ export class Pushy {
|
|
|
427
435
|
this.report({
|
|
428
436
|
type: 'errorUpdate',
|
|
429
437
|
data: { newVersion: hash },
|
|
438
|
+
message: errorMessages.join(';'),
|
|
430
439
|
});
|
|
431
440
|
if (lastError) {
|
|
432
441
|
throw lastError;
|
|
@@ -512,4 +521,8 @@ export class Pushy {
|
|
|
512
521
|
}
|
|
513
522
|
|
|
514
523
|
// for international users
|
|
515
|
-
export class Cresc extends Pushy {
|
|
524
|
+
export class Cresc extends Pushy {
|
|
525
|
+
constructor(options: ClientOptions) {
|
|
526
|
+
super(options, 'Cresc');
|
|
527
|
+
}
|
|
528
|
+
}
|