From d99555a4a8873a6ffb853011c81dc7ed6cc9c0b0 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 20 Jul 2018 15:29:38 +0200 Subject: [PATCH] feat(xo-server/backupNg): remove incomplete XVAs (#3215) Fixes #3159 --- CHANGELOG.md | 1 + packages/xo-server/src/xo-mixins/backups-ng/index.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f69f763aa..ffb0064be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [Backup Reports] Report not sent if reportWhen failure and at least a VM is successfull [#3181](https://github.com/vatesfr/xen-orchestra/issues/3181) (PR [#3185](https://github.com/vatesfr/xen-orchestra/pull/3185)) - [Backup NG] Correctly migrate report setting from legacy jobs [#3180](https://github.com/vatesfr/xen-orchestra/issues/3180) (PR [#3206](https://github.com/vatesfr/xen-orchestra/pull/3206)) +- [Backup NG] remove incomplete XVA files [#3159](https://github.com/vatesfr/xen-orchestra/issues/3159) (PR [#3215](https://github.com/vatesfr/xen-orchestra/pull/3215)) ### Released packages diff --git a/packages/xo-server/src/xo-mixins/backups-ng/index.js b/packages/xo-server/src/xo-mixins/backups-ng/index.js index e19d827bf..f81bf41e5 100644 --- a/packages/xo-server/src/xo-mixins/backups-ng/index.js +++ b/packages/xo-server/src/xo-mixins/backups-ng/index.js @@ -155,6 +155,7 @@ const getVmBackupDir = (uuid: string) => `${BACKUP_DIR}/${uuid}` const isHiddenFile = (filename: string) => filename[0] === '.' const isMetadataFile = (filename: string) => filename.endsWith('.json') const isVhd = (filename: string) => filename.endsWith('.vhd') +const isXva = (filename: string) => filename.endsWith('.xva') const listReplicatedVms = ( xapi: Xapi, @@ -966,6 +967,16 @@ export default class BackupNg { async (taskId, { handler, id: remoteId }) => { const fork = forkExport() + // remove incomplete XVAs + await asyncMap( + handler.list(vmDir, { + filter: filename => + isHiddenFile(filename) && isXva(filename), + prependDir: true, + }), + file => handler.unlink(file) + )::ignoreErrors() + const oldBackups: MetadataFull[] = (getOldEntries( exportRetention, await this._listVmBackups(