From 1d76130a7ca37ba5f85948033abbd56b546b8fee Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Fri, 20 Nov 2020 06:48:21 -0800 Subject: [PATCH] Allow disabling purge interval Fixes #399 --- src/LocalStorageManager.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/LocalStorageManager.ts b/src/LocalStorageManager.ts index e0dd8fe..0214504 100644 --- a/src/LocalStorageManager.ts +++ b/src/LocalStorageManager.ts @@ -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.`, + ); + } } /** @@ -110,7 +118,10 @@ async function purgeOldFiles(): Promise { ); log.verbose("Local storage", "Purge complete"); - _backgroundTimer = setTimeout(purgeOldFiles, Settings.purgeInterval * _millisecondsInAMinute); + + if (Settings.purgeInterval > 0 ) { + _backgroundTimer = setTimeout(purgeOldFiles, Settings.purgeInterval * _millisecondsInAMinute); + } } /**