Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling purge interval #401

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 5.6.0

- Support disabling auto-purge by specifying a `purgeInterval` of `0`. Resolves [issue 399](https://github.com/danecreekphotography/node-deepstackai-trigger/issues/399).

## 5.5.1

- Resolve an issue where the system fails to start if no secrets file exists but the existing `settings.json` or `triggers.json` file uses
Expand Down
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