fix: make sure backups are correctly sorted for clean up

This commit is contained in:
izzy
2025-11-21 18:19:08 +00:00
parent b46d6cda65
commit 534a9f50b6
2 changed files with 4 additions and 2 deletions

View File

@@ -56,7 +56,10 @@ export class BackupService extends BaseService {
const backupsFolder = StorageCore.getBaseFolder(StorageFolder.Backups);
const files = await this.storageRepository.readdir(backupsFolder);
const backups = files.filter((fn) => isValidRoutineBackupName(fn));
const backups = files
.filter((fn) => isValidRoutineBackupName(fn))
.toSorted()
.toReversed();
const failedBackups = files.filter((fn) => isFailedBackupName(fn));
const toDelete = backups.slice(config.keepLastAmount);

View File

@@ -151,7 +151,6 @@ describe(MaintenanceService.name, () => {
'immich-db-backup-20250727T110116-v1.234.5-pg14.5.sql.gz',
'immich-db-backup-1753789649000.sql.gz',
],
failedBackups: ['immich-db-backup-20250725T110216-v1.234.5-pg14.5.sql.gz.tmp'],
});
});
});