Set the maximum number of backups via config
| @@ -48,6 +48,8 @@ allowKeysExposure: false | |||
| 48 | skipContentCheck: false | 48 | skipContentCheck: false |
| 49 | # Disable automatic chats backup | 49 | # Disable automatic chats backup |
| 50 | disableChatBackup: false | 50 | disableChatBackup: false |
| 51 | # Number of backups to keep for each chat and settings file | ||
| 52 | numberOfBackups: 50 | ||
| 51 | # Allowed hosts for card downloads | 53 | # Allowed hosts for card downloads |
| 52 | whitelistImportDomains: | 54 | whitelistImportDomains: |
| 53 | - localhost | 55 | - localhost |
| @@ -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 | */ |
| 373 | function removeOldBackups(directory, prefix) { | 373 | function removeOldBackups(directory, prefix) { |
| 374 | const MAX_BACKUPS = 50; | 374 | const MAX_BACKUPS = Number(getConfigValue('numberOfBackups', 50)); |
| 375 | 375 | ||
| 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) { |