1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-01 13:53:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

add back full update

This commit is contained in:
sunnylqm
2022-04-27 21:52:38 +08:00
parent ead8f8cac5
commit ea1a8dfad2
5 changed files with 32 additions and 24 deletions

View File

@@ -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;
}