Set the maximum number of backups via config

This commit is contained in:
Cohee 2024-07-01 01:17:56 +03:00
parent b3f657bed5
commit ce18b33e73
2 changed files with 3 additions and 1 deletions

View File

@ -48,6 +48,8 @@ allowKeysExposure: false
skipContentCheck: false
# Disable automatic chats backup
disableChatBackup: false
# Number of backups to keep for each chat and settings file
numberOfBackups: 50
# Allowed hosts for card downloads
whitelistImportDomains:
- localhost

View File

@ -371,7 +371,7 @@ function generateTimestamp() {
* @param {string} prefix File prefix to filter backups by.
*/
function removeOldBackups(directory, prefix) {
const MAX_BACKUPS = 50;
const MAX_BACKUPS = Number(getConfigValue('numberOfBackups', 50));
let files = fs.readdirSync(directory).filter(f => f.startsWith(prefix));
if (files.length > MAX_BACKUPS) {