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`);
|
logger(`duplicated downloaded hash ${downloadedHash}, ignored`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (readyHash) {
|
||||||
|
logger(`hash ${readyHash} applied. reboot first`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (downloadingThrottling) {
|
if (downloadingThrottling) {
|
||||||
logger('repeated downloading, ignored');
|
logger('repeated downloading, ignored');
|
||||||
return;
|
return;
|
||||||
@ -215,21 +219,34 @@ export async function downloadUpdate(options, eventListeners) {
|
|||||||
return options.hash;
|
return options.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function switchVersion(hash) {
|
|
||||||
assertRelease();
|
|
||||||
logger('switchVersion');
|
|
||||||
Pushy.reloadUpdate({ hash });
|
|
||||||
}
|
|
||||||
|
|
||||||
let readyHash;
|
let readyHash;
|
||||||
export function switchVersionLater(hash) {
|
function assertHash(hash) {
|
||||||
assertRelease();
|
if (!downloadedHash) {
|
||||||
|
logger(`no downloaded hash`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (hash !== downloadedHash) {
|
||||||
|
logger(`use downloaded hash ${downloadedHash} first`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (readyHash === hash) {
|
if (readyHash === hash) {
|
||||||
logger(`duplicated ready hash ${readyHash}, ignored`);
|
logger(`hash ${readyHash} already applied. reboot first.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
readyHash = hash;
|
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 });
|
Pushy.setNeedUpdate({ hash });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user