mirror of https://github.com/gorhill/uBlock.git
code review: not all assets have remote home
This commit is contained in:
parent
bc676df0d6
commit
fb51b57152
22
js/assets.js
22
js/assets.js
|
@ -543,12 +543,15 @@ 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 timestamp = entries[path];
|
||||
var obsolete = Date.now() - exports.autoUpdateDelay;
|
||||
if ( exports.autoUpdate && (typeof timestamp !== 'number' || timestamp <= obsolete) ) {
|
||||
//console.log('µBlock> readRepoCopyAsset("%s") / onCacheMetaReady(): not cached or obsolete', path);
|
||||
getTextFileFromURL(assetEntry.homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
return;
|
||||
var homeURL = assetEntry.homeURL;
|
||||
if ( exports.autoUpdate && typeof homeURL === 'string' && homeURL !== '' ) {
|
||||
var timestamp = entries[path];
|
||||
var obsolete = Date.now() - exports.autoUpdateDelay;
|
||||
if ( typeof timestamp !== 'number' || timestamp <= obsolete ) {
|
||||
//console.log('µBlock> readRepoCopyAsset("%s") / onCacheMetaReady(): not cached or obsolete', path);
|
||||
getTextFileFromURL(homeURL, onHomeFileLoaded, onHomeFileError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// In cache
|
||||
|
@ -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