fix(xo-web/backup-ng): delete backups sequentially (#2855)

- sequentially: to limit merge issues
- from newest to oldest: to avoid unnecessary merges
This commit is contained in:
Julien Fontanet 2018-04-23 16:35:34 +02:00 committed by GitHub
parent b3ae9d88eb
commit e45f78ea20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1753,7 +1753,13 @@ export const restoreBackup = (backup, sr, startOnRestore) => {
export const deleteBackup = backup =>
_call('backupNg.deleteVmBackup', { id: resolveId(backup) })
export const deleteBackups = backups => Promise.all(map(backups, deleteBackup))
export const deleteBackups = async backups => {
// delete sequentially from newest to oldest
backups = backups.slice().sort((b1, b2) => b2.timestamp - b1.timestamp)
for (let i = 0, n = backups.length; i < n; ++i) {
await deleteBackup(backups[i])
}
}
// Plugins -----------------------------------------------------------