Skip to content

Commit

Permalink
Fix spurious update cycle attempts
Browse files Browse the repository at this point in the history
Caused by the fact that external filter lists do not have an
`off` property even when they are not enabled.

Additionally, set the default update cycle check period to 2hr.
  • Loading branch information
gorhill committed Mar 27, 2023
1 parent 10f9559 commit 885b3ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const hiddenSettingsDefault = {
autoCommentFilterTemplate: '{{date}} {{origin}}',
autoUpdateAssetFetchPeriod: 60,
autoUpdateDelayAfterLaunch: 105,
autoUpdatePeriod: 4,
autoUpdatePeriod: 2,
benchmarkDatasetURL: 'unset',
blockingProfiles: '11111/#F00 11010/#C0F 11001/#00F 00001',
cacheStorageAPI: 'unset',
Expand Down
12 changes: 9 additions & 3 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,13 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
const now = Date.now();

let needEmergencyUpdate = false;
for ( const asset of Object.values(assetDict) ) {
for ( const [ assetKey, asset ] of Object.entries(assetDict) ) {
if ( asset.hasRemoteURL !== true ) { continue; }
if ( asset.content === 'filters' && asset.off === true ) { continue; }
if ( asset.content === 'filters' ) {
if ( µb.selectedFilterLists.includes(assetKey) === false ) {
continue;
}
}
if ( asset.obsolete !== true ) { continue; }
const lastUpdateInDays = (now - asset.writeTime) / 86400000;
const daysSinceVeryObsolete = lastUpdateInDays - 2 * asset.updateAfter;
Expand Down Expand Up @@ -1602,7 +1606,9 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
this.loadFilterLists();
}
if ( this.userSettings.autoUpdate ) {
this.scheduleAssetUpdater(this.hiddenSettings.autoUpdatePeriod * 3600000 || 25200000);
this.scheduleAssetUpdater(
this.hiddenSettings.autoUpdatePeriod * 3600000 || 25200000
);
} else {
this.scheduleAssetUpdater(0);
}
Expand Down

0 comments on commit 885b3ea

Please sign in to comment.