mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-01 13:53:11 +08:00
add back full update
This commit is contained in:
42
lib/main.js
42
lib/main.js
@@ -95,7 +95,7 @@ export const cInfo = {
|
||||
|
||||
function assertRelease() {
|
||||
if (__DEV__) {
|
||||
throw new Error('react-native-update can only run on RELEASE version.');
|
||||
throw new Error('react-native-update 只能在 RELEASE 版本中运行.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ export async function checkUpdate(APPKEY, isRetry) {
|
||||
});
|
||||
} catch (e) {
|
||||
if (isRetry) {
|
||||
throw new Error('Could not connect to pushy server');
|
||||
throw new Error('无法连接更新服务器,请检查网络连接后重试');
|
||||
}
|
||||
await tryBackupEndpoints(APPKEY);
|
||||
return checkUpdate(APPKEY, true);
|
||||
@@ -209,6 +209,7 @@ export async function downloadUpdate(options, eventListeners) {
|
||||
);
|
||||
}
|
||||
}
|
||||
let succeeded = false;
|
||||
if (options.diffUrl) {
|
||||
logger('downloading diff');
|
||||
try {
|
||||
@@ -217,38 +218,45 @@ export async function downloadUpdate(options, eventListeners) {
|
||||
hash: options.hash,
|
||||
originHash: currentVersion,
|
||||
});
|
||||
succeeded = true;
|
||||
} catch (e) {
|
||||
logger(`diff error: ${e.message}, try pdiff`);
|
||||
try {
|
||||
await Pushy.downloadPatchFromPackage({
|
||||
updateUrl: options.pdiffUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
} catch (e) {
|
||||
progressHandler && progressHandler.remove();
|
||||
report(options.hash, 'error');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else if (options.pdiffUrl) {
|
||||
}
|
||||
if (!succeeded && options.pdiffUrl) {
|
||||
logger('downloading pdiff');
|
||||
try {
|
||||
await Pushy.downloadPatchFromPackage({
|
||||
updateUrl: options.pdiffUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
succeeded = true;
|
||||
} catch (e) {
|
||||
progressHandler && progressHandler.remove();
|
||||
report(options.hash, 'error');
|
||||
throw e;
|
||||
logger(`pdiff error: ${e.message}, try full patch`);
|
||||
}
|
||||
}
|
||||
if (!succeeded && options.updateUrl) {
|
||||
logger('downloading full patch');
|
||||
try {
|
||||
await Pushy.downloadFullUpdate({
|
||||
updateUrl: options.updateUrl,
|
||||
hash: options.hash,
|
||||
});
|
||||
succeeded = true;
|
||||
} catch (e) {
|
||||
logger(`full patch error: ${e.message}`);
|
||||
}
|
||||
}
|
||||
progressHandler && progressHandler.remove();
|
||||
if (!succeeded) {
|
||||
report(options.hash, 'error');
|
||||
throw new Error('all update attempts failed');
|
||||
}
|
||||
setLocalHashInfo(options.hash, {
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
metaInfo: options.metaInfo,
|
||||
});
|
||||
progressHandler && progressHandler.remove();
|
||||
downloadedHash = options.hash;
|
||||
return options.hash;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user