Skip to content

Commit

Permalink
fix(@xen-orchestra/backups): clean VM immediatly after selecting back…
Browse files Browse the repository at this point in the history
…up to be deleted
  • Loading branch information
fbeauchamp committed Jan 6, 2022
1 parent 5338080 commit 98c0de9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
9 changes: 7 additions & 2 deletions @xen-orchestra/backups/RemoteAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ class RemoteAdapter {
async deleteDeltaVmBackups(backups) {
const handler = this._handler

// unused VHDs will be detected by `cleanVm`
await asyncMapSettled(backups, ({ _filename }) => VhdAbstract.unlink(handler, _filename))
// this will delete the json, unused VHDs will be detected by `cleanVm`
await asyncMapSettled(backups, ({ _filename }) => handler.unlink(_filename))
}

async deleteMetadataBackup(backupId) {
Expand Down Expand Up @@ -277,6 +277,11 @@ class RemoteAdapter {
delta !== undefined && this.deleteDeltaVmBackups(delta),
full !== undefined && this.deleteFullVmBackups(full),
])

const dirs = new Set(files.map(file => dirname(file)))
for(const dir of dirs){
await this.cleanVm(dir, {remove: true, onLog: warn })
}
}

#getCompressionType() {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### Bug fixes

> Users must be able to say: “I had this issue, happy to know it's fixed”
- [Backup] : delete backups immediatly after selecting them instead of waiting for the next backup successfull execution (PR [#6081](https://github.com/vatesfr/xen-orchestra/pull/6081))

### Packages to release

Expand Down
8 changes: 1 addition & 7 deletions packages/xo-web/src/common/xo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2221,13 +2221,7 @@ export const restoreBackup = (backup, sr, { generateNewMacAddresses = false, sta

export const deleteBackup = backup => _call('backupNg.deleteVmBackup', { id: resolveId(backup) })

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])
}
}
export const deleteBackups = async backups => _call('backupNg.deleteVmBackups', { ids: backups.map(backup => resolveId(backup)) })

export const createMetadataBackupJob = props =>
_call('metadataBackup.createJob', props)
Expand Down

0 comments on commit 98c0de9

Please sign in to comment.