diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ddf3387421..48204eb9d3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - [Backup NG] Don't fail on VMs with empty VBDs (like CDs or floppy disks) (PR [#3410](https://github.com/vatesfr/xen-orchestra/pull/3410)) - [XOA updater] Fix issue where trial request would fail [#3407](https://github.com/vatesfr/xen-orchestra/issues/3407) (PR [#3412](https://github.com/vatesfr/xen-orchestra/pull/3412)) - [Backup NG logs] Fix log's value not being updated in the copy and report button [#3273](https://github.com/vatesfr/xen-orchestra/issues/3273) (PR [#3360](https://github.com/vatesfr/xen-orchestra/pull/3360)) +- [Backup NG] Fix issue when *Delete first* was enabled for some of the remotes [#3424](https://github.com/vatesfr/xen-orchestra/issues/3424) (PR [#3427](https://github.com/vatesfr/xen-orchestra/pull/3427)) ### 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 b895ce6a694..102e333a6f5 100644 --- a/packages/xo-server/src/xo-mixins/backups-ng/index.js +++ b/packages/xo-server/src/xo-mixins/backups-ng/index.js @@ -1227,17 +1227,28 @@ export default class BackupNg { const streams: any = mapValues( deltaExport.streams, lazyStream => { - const pStream = lazyStream() - const forks = Array.from({ length: nTargets }, _ => { - const promise = pStream.then(stream => { - const fork: any = stream.pipe(new PassThrough()) - fork.task = stream.task - return fork - }) - promise.catch(noop) // prevent unhandled rejection - return promise - }) - return () => forks.pop() + // wait for all targets to require the stream and then starts + // the real export and create the forks. + const resolves = [] + function resolver (resolve) { + resolves.push(resolve) + + if (resolves.length === nTargets) { + const pStream = lazyStream() + resolves.forEach(resolve => { + resolve( + pStream.then(stream => { + const fork: any = stream.pipe(new PassThrough()) + fork.task = stream.task + return fork + }) + ) + }) + resolves.length = 0 + } + } + + return () => new Promise(resolver) } ) return () => {