feat(vhd-lib): implement a limit in VhdSynthetic.fromVhdChain
This commit is contained in:
committed by
Julien Fontanet
parent
408fc5af84
commit
b29d5ba95c
@@ -120,7 +120,8 @@ const VhdSynthetic = class VhdSynthetic extends VhdAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add decorated static method
|
// add decorated static method
|
||||||
VhdSynthetic.fromVhdChain = Disposable.factory(async function* fromVhdChain(handler, childPath) {
|
// until is not included in the result , the chain will stop at its child
|
||||||
|
VhdSynthetic.fromVhdChain = Disposable.factory(async function* fromVhdChain(handler, childPath, { until } = {}) {
|
||||||
let vhdPath = childPath
|
let vhdPath = childPath
|
||||||
let vhd
|
let vhd
|
||||||
const vhds = []
|
const vhds = []
|
||||||
@@ -128,8 +129,11 @@ VhdSynthetic.fromVhdChain = Disposable.factory(async function* fromVhdChain(hand
|
|||||||
vhd = yield openVhd(handler, vhdPath)
|
vhd = yield openVhd(handler, vhdPath)
|
||||||
vhds.unshift(vhd) // from oldest to most recent
|
vhds.unshift(vhd) // from oldest to most recent
|
||||||
vhdPath = resolveRelativeFromFile(vhdPath, vhd.header.parentUnicodeName)
|
vhdPath = resolveRelativeFromFile(vhdPath, vhd.header.parentUnicodeName)
|
||||||
} while (vhd.footer.diskType !== DISK_TYPES.DYNAMIC)
|
} while (vhd.footer.diskType !== DISK_TYPES.DYNAMIC && vhdPath !== until)
|
||||||
|
|
||||||
|
if (until !== undefined && vhdPath !== until) {
|
||||||
|
throw new Error(`Didn't find ${until} as a parent of ${childPath}`)
|
||||||
|
}
|
||||||
const synthetic = new VhdSynthetic(vhds)
|
const synthetic = new VhdSynthetic(vhds)
|
||||||
await synthetic.readHeaderAndFooter()
|
await synthetic.readHeaderAndFooter()
|
||||||
yield synthetic
|
yield synthetic
|
||||||
|
|||||||
Reference in New Issue
Block a user