Check hash more strict
This commit is contained in:
parent
451e298ba5
commit
b193b4b1df
37
lib/index.js
37
lib/index.js
@ -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 });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user