Set the maximum number of backups via config

ce18b33e738e9daf632640a7442bb72d945d7f1a

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +3 -1Ignore whitespace
default/config.yaml+2 -0
@@ -48,6 +48,8 @@ allowKeysExposure: false
48skipContentCheck: false48skipContentCheck: false
49# Disable automatic chats backup49# Disable automatic chats backup
50disableChatBackup: false50disableChatBackup: false
51# Number of backups to keep for each chat and settings file
52numberOfBackups: 50
51# Allowed hosts for card downloads53# Allowed hosts for card downloads
52whitelistImportDomains:54whitelistImportDomains:
53 - localhost55 - localhost
src/util.js+1 -1
@@ -371,7 +371,7 @@ function generateTimestamp() {
371 * @param {string} prefix File prefix to filter backups by.371 * @param {string} prefix File prefix to filter backups by.
372 */372 */
373function removeOldBackups(directory, prefix) {373function removeOldBackups(directory, prefix) {
374 const MAX_BACKUPS = 50;374 const MAX_BACKUPS = Number(getConfigValue('numberOfBackups', 50));
375375
376 let files = fs.readdirSync(directory).filter(f => f.startsWith(prefix));376 let files = fs.readdirSync(directory).filter(f => f.startsWith(prefix));
377 if (files.length > MAX_BACKUPS) {377 if (files.length > MAX_BACKUPS) {