fix(deltaBackups): update checksum after altering VHD files (#408)
Fixes vatesfr/xo-web#1606
This commit is contained in:
parent
3944b8aaee
commit
bdeb5895f6
@ -154,6 +154,13 @@ export default class RemoteHandlerAbstract {
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
|
||||
async refreshChecksum (path) {
|
||||
const stream = addChecksumToReadStream(await this.createReadStream(path))
|
||||
stream.resume() // start reading the whole file
|
||||
const checksum = await stream.checksum
|
||||
await this.outputFile(`${path}.checksum`, checksum)
|
||||
}
|
||||
|
||||
async createOutputStream (file, {
|
||||
checksum = false,
|
||||
...options
|
||||
|
@ -572,6 +572,7 @@ export default async function vhdMerge (
|
||||
await parentVhd.writeFooter()
|
||||
}
|
||||
|
||||
// returns true if the child was actually modified
|
||||
export async function chainVhd (
|
||||
parentHandler, parentPath,
|
||||
childHandler, childPath
|
||||
@ -588,5 +589,7 @@ export async function chainVhd (
|
||||
childVhd.header.parentUuid = parentUuid
|
||||
childVhd.header.parentUnicodeName = parentName
|
||||
await childVhd.writeHeader()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -295,7 +295,11 @@ export default class {
|
||||
async _chainDeltaVdiBackups ({handler, dir}) {
|
||||
const backups = await this._listVdiBackups(handler, dir)
|
||||
for (let i = 1; i < backups.length; i++) {
|
||||
await chainVhd(handler, dir + '/' + backups[i - 1], handler, dir + '/' + backups[i])
|
||||
const childPath = dir + '/' + backups[i]
|
||||
const modified = await chainVhd(handler, dir + '/' + backups[i - 1], handler, childPath)
|
||||
if (modified) {
|
||||
await handler.refreshChecksum(childPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user