mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
code review: not all assets have remote home
This commit is contained in:
parent
bc676df0d6
commit
fb51b57152
14
js/assets.js
14
js/assets.js
@ -543,13 +543,16 @@ var readRepoCopyAsset = function(path, callback) {
|
||||
var onCacheMetaReady = function(entries) {
|
||||
// Fetch from remote if:
|
||||
// - Auto-update enabled AND (not in cache OR in cache but obsolete)
|
||||
var homeURL = assetEntry.homeURL;
|
||||
if ( exports.autoUpdate && typeof homeURL === 'string' && homeURL !== '' ) {
|
||||
var timestamp = entries[path];
|
||||
var obsolete = Date.now() - exports.autoUpdateDelay;
|
||||
if ( exports.autoUpdate && (typeof timestamp !== 'number' || timestamp <= obsolete) ) {
|
||||
if ( typeof timestamp !== 'number' || timestamp <= obsolete ) {
|
||||
//console.log('µBlock> readRepoCopyAsset("%s") / onCacheMetaReady(): not cached or obsolete', path);
|
||||
getTextFileFromURL(assetEntry.homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
getTextFileFromURL(homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// In cache
|
||||
if ( typeof timestamp === 'number' ) {
|
||||
@ -573,7 +576,12 @@ var readRepoCopyAsset = function(path, callback) {
|
||||
// Repo copy changed: fetch from home URL
|
||||
if ( exports.autoUpdate && assetEntry.localChecksum !== assetEntry.repoChecksum ) {
|
||||
//console.log('µBlock> readRepoCopyAsset("%s") / onRepoMetaReady(): repo has newer version', path);
|
||||
getTextFileFromURL(assetEntry.homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
var homeURL = assetEntry.homeURL;
|
||||
if ( typeof homeURL === 'string' && homeURL !== '' ) {
|
||||
getTextFileFromURL(homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
} else {
|
||||
getTextFileFromURL(repositoryURL, onRepoFileLoaded, onRepoFileError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user