fix(backups/ImportVmBackup): use transfered size instead of backup size
Backup size is smaller in case of delta VHDs.
This commit is contained in:
parent
6f626974ac
commit
9b1fbf0fbf
@ -3,6 +3,7 @@ const assert = require('assert')
|
||||
const { formatFilenameDate } = require('./_filenameDate')
|
||||
const { importDeltaVm } = require('./_deltaVm')
|
||||
const { Task } = require('./Task')
|
||||
const { watchStreamSize } = require('./_watchStreamSize')
|
||||
|
||||
exports.ImportVmBackup = class ImportVmBackup {
|
||||
constructor({ adapter, metadata, srUuid, xapi, settings: { newMacAddresses } = {} }) {
|
||||
@ -18,13 +19,17 @@ exports.ImportVmBackup = class ImportVmBackup {
|
||||
const metadata = this._metadata
|
||||
const isFull = metadata.mode === 'full'
|
||||
|
||||
const sizeContainer = { size: 0 }
|
||||
|
||||
let backup
|
||||
if (isFull) {
|
||||
backup = await adapter.readFullVmBackup(metadata)
|
||||
watchStreamSize(backup, sizeContainer)
|
||||
} else {
|
||||
assert.strictEqual(metadata.mode, 'delta')
|
||||
|
||||
backup = await adapter.readDeltaVmBackup(metadata)
|
||||
Object.values(backup.streams).forEach(stream => watchStreamSize(stream, sizeContainer))
|
||||
}
|
||||
|
||||
return Task.run(
|
||||
@ -52,7 +57,7 @@ exports.ImportVmBackup = class ImportVmBackup {
|
||||
])
|
||||
|
||||
return {
|
||||
size: metadata.size,
|
||||
size: sizeContainer.size,
|
||||
id: await xapi.getField('VM', vmRef, 'uuid'),
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
exports.watchStreamSize = function watchStreamSize(stream) {
|
||||
const container = { size: 0 }
|
||||
exports.watchStreamSize = function watchStreamSize(stream, container = { size: 0 }) {
|
||||
stream.on('data', data => {
|
||||
container.size += data.length
|
||||
})
|
||||
|
@ -17,6 +17,7 @@
|
||||
- [Backup] Fix `vm.refresh_snapshots is not a function` error
|
||||
- [Backup] Fix `cannot read property "length" of undefined` when using _delete first_ [Forum post](https://xcp-ng.org/forum/topic/4440/error-on-delta-backup-cannot-read-property-length-of-undefined)
|
||||
- [Delta backup] Fix merge task not under corresponding remote and missing merge size in summary [#5708](https://github.com/vatesfr/xen-orchestra/issues/5708)
|
||||
- [Delta backup restore] Fix incorrect reported size (and speed)
|
||||
- [Settings/Logs] Correctly hide `pool.listMissingPatches` and `host.stats` errors
|
||||
- [Plugins] Fix `strict mode: unknown keyword` when configuring some plugins
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user