mirror of https://github.com/gorhill/uBlock.git
Prevent reload if updated version is higher than current
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/717 Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/717#issuecomment-528921730
This commit is contained in:
parent
c55288281c
commit
c8c2e11d09
|
@ -78,6 +78,27 @@ vAPI.app = {
|
||||||
return version;
|
return version;
|
||||||
})(),
|
})(),
|
||||||
|
|
||||||
|
intFromVersion: function(s) {
|
||||||
|
const parts = s.match(/(?:^|\.|b|rc)\d+/g);
|
||||||
|
if ( parts === null ) { return 0; }
|
||||||
|
let vint = 0;
|
||||||
|
for ( let i = 0; i < 4; i++ ) {
|
||||||
|
const pstr = parts[i] || '';
|
||||||
|
let pint;
|
||||||
|
if ( pstr === '' ) {
|
||||||
|
pint = 0;
|
||||||
|
} else if ( pstr.startsWith('.') || pstr.startsWith('b') ) {
|
||||||
|
pint = parseInt(pstr.slice(1), 10);
|
||||||
|
} else if ( pstr.startsWith('rc') ) {
|
||||||
|
pint = parseInt(pstr.slice(2), 10) + 100;
|
||||||
|
} else {
|
||||||
|
pint = parseInt(pstr, 10);
|
||||||
|
}
|
||||||
|
vint = vint * 1000 + pint;
|
||||||
|
}
|
||||||
|
return vint;
|
||||||
|
},
|
||||||
|
|
||||||
restart: function() {
|
restart: function() {
|
||||||
browser.runtime.reload();
|
browser.runtime.reload();
|
||||||
},
|
},
|
||||||
|
@ -85,8 +106,10 @@ vAPI.app = {
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/717
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/717
|
||||||
// Prevent the extensions from being restarted mid-session.
|
// Prevent the extensions from being restarted mid-session.
|
||||||
browser.runtime.onUpdateAvailable.addListener(( ) => {
|
browser.runtime.onUpdateAvailable.addListener(details => {
|
||||||
void 0;
|
const toInt = vAPI.app.intFromVersion;
|
||||||
|
if ( toInt(details.version) > toInt(vAPI.app.version) ) { return; }
|
||||||
|
browser.runtime.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -181,30 +181,7 @@ const onVersionReady = function(lastVersion) {
|
||||||
// force a reload of all resources.
|
// force a reload of all resources.
|
||||||
µb.redirectEngine.invalidateResourcesSelfie();
|
µb.redirectEngine.invalidateResourcesSelfie();
|
||||||
|
|
||||||
// If unused, just comment out for when we need to compare versions in the
|
const lastVersionInt = vAPI.app.intFromVersion(lastVersion);
|
||||||
// future.
|
|
||||||
const intFromVersion = function(s) {
|
|
||||||
const parts = s.match(/(?:^|\.|b|rc)\d+/g);
|
|
||||||
if ( parts === null ) { return 0; }
|
|
||||||
let vint = 0;
|
|
||||||
for ( let i = 0; i < 4; i++ ) {
|
|
||||||
const pstr = parts[i] || '';
|
|
||||||
let pint;
|
|
||||||
if ( pstr === '' ) {
|
|
||||||
pint = 0;
|
|
||||||
} else if ( pstr.startsWith('.') || pstr.startsWith('b') ) {
|
|
||||||
pint = parseInt(pstr.slice(1), 10);
|
|
||||||
} else if ( pstr.startsWith('rc') ) {
|
|
||||||
pint = parseInt(pstr.slice(2), 10) + 100;
|
|
||||||
} else {
|
|
||||||
pint = parseInt(pstr, 10);
|
|
||||||
}
|
|
||||||
vint = vint * 1000 + pint;
|
|
||||||
}
|
|
||||||
return vint;
|
|
||||||
};
|
|
||||||
|
|
||||||
const lastVersionInt = intFromVersion(lastVersion);
|
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/494
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/494
|
||||||
// Remove useless per-site switches.
|
// Remove useless per-site switches.
|
||||||
|
@ -214,14 +191,6 @@ const onVersionReady = function(lastVersion) {
|
||||||
µb.saveHostnameSwitches();
|
µb.saveHostnameSwitches();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/212#issuecomment-419741324
|
|
||||||
if ( lastVersionInt <= 1015024000 ) {
|
|
||||||
if ( µb.hiddenSettings.manualUpdateAssetFetchPeriod === 2000 ) {
|
|
||||||
µb.hiddenSettings.manualUpdateAssetFetchPeriod = 500;
|
|
||||||
µb.saveHiddenSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vAPI.storage.set({ version: vAPI.app.version });
|
vAPI.storage.set({ version: vAPI.app.version });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue