fix(backup, vhd-lib): merge now return the resulting size and merged size

This commit is contained in:
Florent Beauchamp 2023-12-07 13:52:11 +00:00 committed by Julien Fontanet
parent 7f8ab07692
commit 7f83a3e55e
3 changed files with 17 additions and 9 deletions

View File

@ -471,17 +471,15 @@ export async function cleanVm(
const metadataWithMergedVhd = {}
const doMerge = async () => {
await asyncMap(toMerge, async chain => {
const merged = await limitedMergeVhdChain(handler, chain, {
await limitedMergeVhdChain(handler, chain, {
logInfo,
logWarn,
remove,
merge,
mergeBlockConcurrency,
})
if (merged !== undefined) {
const metadataPath = vhdsToJSons[chain[chain.length - 1]] // all the chain should have the same metada file
metadataWithMergedVhd[metadataPath] = true
}
})
const metadataPath = vhdsToJSons[chain[chain.length - 1]] // all the chain should have the same metada file
metadataWithMergedVhd[metadataPath] = true
})
}

View File

@ -46,7 +46,7 @@
- @vates/nbd-client major
- @xen-orchestra/backups patch
- @xen-orchestra/xapi minor
- vhd-lib patch
- vhd-lib minor
- xo-server minor
- xo-server-auth-saml minor
- xo-server-transport-email major

View File

@ -223,6 +223,15 @@ class Merger {
)
// ensure data size is correct
await this.#writeState()
try {
// vhd file
this.#state.vhdSize = await parentVhd.getSize()
} catch (err) {
// vhd directory
// parentVhd has its bat already loaded
this.#state.vhdSize = parentVhd.streamSize()
}
this.#onProgress({ total: nBlocks, done: nBlocks })
}
@ -294,9 +303,10 @@ class Merger {
}
async #cleanup() {
const mergedSize = this.#state?.mergedDataSize ?? 0
const finalVhdSize = this.#state?.vhdSize ?? 0
const mergedDataSize = this.#state?.mergedDataSize ?? 0
await this.#handler.unlink(this.#statePath).catch(warn)
return mergedSize
return { mergedDataSize, finalVhdSize}
}
}