Skip to content

Commit

Permalink
Allow disabling purge interval
Browse files Browse the repository at this point in the history
Fixes #399
  • Loading branch information
neilenns committed Nov 20, 2020
1 parent 71d2bf9 commit 1d76130
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/LocalStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,19 @@ export async function copyToLocalStorage(location: Locations, fileName: string):
* Starts a background task that purges old files from local storage.
*/
export function startBackgroundPurge(): void {
log.verbose(
"Local storage",
`Enabling background purge every ${Settings.purgeInterval} minutes for files older than ${Settings.purgeAge} minutes.`,
);
purgeOldFiles();
if (Settings.purgeInterval > 0) {
log.verbose(
"Local storage",
`Enabling background purge every ${Settings.purgeInterval} minutes for files older than ${Settings.purgeAge} minutes.`,
);
purgeOldFiles();
}
else {
log.verbose(
"Local storage",
`Background purge is disabled via settings.`,
);
}
}

/**
Expand Down Expand Up @@ -110,7 +118,10 @@ async function purgeOldFiles(): Promise<void> {
);

log.verbose("Local storage", "Purge complete");
_backgroundTimer = setTimeout(purgeOldFiles, Settings.purgeInterval * _millisecondsInAMinute);

if (Settings.purgeInterval > 0 ) {
_backgroundTimer = setTimeout(purgeOldFiles, Settings.purgeInterval * _millisecondsInAMinute);
}
}

/**
Expand Down

0 comments on commit 1d76130

Please sign in to comment.