1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

Check hash more strict

This commit is contained in:
sunnylqm 2021-08-22 11:33:54 +08:00
parent 451e298ba5
commit b193b4b1df

View File

@ -165,6 +165,10 @@ export async function downloadUpdate(options, eventListeners) {
logger(`duplicated downloaded hash ${downloadedHash}, ignored`);
return;
}
if (readyHash) {
logger(`hash ${readyHash} applied. reboot first`);
return;
}
if (downloadingThrottling) {
logger('repeated downloading, ignored');
return;
@ -215,21 +219,34 @@ export async function downloadUpdate(options, eventListeners) {
return options.hash;
}
export function switchVersion(hash) {
assertRelease();
logger('switchVersion');
Pushy.reloadUpdate({ hash });
}
let readyHash;
export function switchVersionLater(hash) {
assertRelease();
function assertHash(hash) {
if (!downloadedHash) {
logger(`no downloaded hash`);
return;
}
if (hash !== downloadedHash) {
logger(`use downloaded hash ${downloadedHash} first`);
return;
}
if (readyHash === hash) {
logger(`duplicated ready hash ${readyHash}, ignored`);
logger(`hash ${readyHash} already applied. reboot first.`);
return;
}
readyHash = hash;
logger('switchVersionLater');
}
export function switchVersion(hash) {
assertRelease();
assertHash(hash);
logger('switchVersion: ' + hash);
Pushy.reloadUpdate({ hash });
}
export function switchVersionLater(hash) {
assertRelease();
assertHash(hash);
logger('switchVersionLater: ' + hash);
Pushy.setNeedUpdate({ hash });
}