Compare commits

...

1 Commits

Author SHA1 Message Date
Florent BEAUCHAMP
ec82acef29 feat(vhd-lib): slim down key backup when using block based backup 2023-06-11 13:47:04 +02:00
2 changed files with 10 additions and 4 deletions

View File

@@ -211,6 +211,7 @@ class IncrementalRemoteWriter extends MixinRemoteWriter(AbstractIncrementalWrite
checksum: false, checksum: false,
validator: tmpPath => checkVhd(handler, tmpPath), validator: tmpPath => checkVhd(handler, tmpPath),
writeBlockConcurrency: this._config.writeBlockConcurrency, writeBlockConcurrency: this._config.writeBlockConcurrency,
isDelta,
}) })
if (isDelta) { if (isDelta) {

View File

@@ -8,8 +8,9 @@ const { asyncEach } = require('@vates/async-each')
const { warn } = createLogger('vhd-lib:createVhdDirectoryFromStream') const { warn } = createLogger('vhd-lib:createVhdDirectoryFromStream')
const buildVhd = Disposable.wrap(async function* (handler, path, inputStream, { concurrency, compression }) { const buildVhd = Disposable.wrap(async function* (handler, path, inputStream, { concurrency, compression, isDelta }) {
const vhd = yield VhdDirectory.create(handler, path, { compression }) const vhd = yield VhdDirectory.create(handler, path, { compression })
const emptyBlock = Buffer.alloc(2 * 1024 * 1024, 0)
await asyncEach( await asyncEach(
parseVhdStream(inputStream), parseVhdStream(inputStream),
async function (item) { async function (item) {
@@ -24,7 +25,11 @@ const buildVhd = Disposable.wrap(async function* (handler, path, inputStream, {
await vhd.writeParentLocator({ ...item, data: item.buffer }) await vhd.writeParentLocator({ ...item, data: item.buffer })
break break
case 'block': case 'block':
await vhd.writeEntireBlock(item) // automatically thin blocks of key backup
// we can't thin block of delta backup since it can be an empty block whom parent block contains data
if (isDelta || !emptyBlock.equals(item.buffer)) {
await vhd.writeEntireBlock(item)
}
break break
case 'bat': case 'bat':
// it exists but I don't care // it exists but I don't care
@@ -45,10 +50,10 @@ exports.createVhdDirectoryFromStream = async function createVhdDirectoryFromStre
handler, handler,
path, path,
inputStream, inputStream,
{ validator, concurrency = 16, compression } = {} { validator, concurrency = 16, compression, isDelta } = {}
) { ) {
try { try {
const size = await buildVhd(handler, path, inputStream, { concurrency, compression }) const size = await buildVhd(handler, path, inputStream, { concurrency, compression, isDelta })
if (validator !== undefined) { if (validator !== undefined) {
await validator.call(this, path) await validator.call(this, path)
} }