fix(vhd-lib/merge): don't delete children if renaming parent failed
Related to https://xcp-ng.org/forum/post/51529
This commit is contained in:
parent
8864c2f2db
commit
bb4504dd50
@ -32,6 +32,7 @@
|
|||||||
- @xen-orchestra/backups patch
|
- @xen-orchestra/backups patch
|
||||||
- @xen-orchestra/mixins minor
|
- @xen-orchestra/mixins minor
|
||||||
- @xen-orchestra/proxy minor
|
- @xen-orchestra/proxy minor
|
||||||
|
- vhd-lib patch
|
||||||
- xo-server minor
|
- xo-server minor
|
||||||
|
|
||||||
<!--packages-end-->
|
<!--packages-end-->
|
||||||
|
@ -55,22 +55,21 @@ function makeThrottledWriter(handler, path, delay) {
|
|||||||
// make the rename / delete part of the merge process
|
// make the rename / delete part of the merge process
|
||||||
// will fail if parent and children are in different remote
|
// will fail if parent and children are in different remote
|
||||||
|
|
||||||
function cleanupVhds(handler, parent, children, { logInfo = noop, remove = false } = {}) {
|
async function cleanupVhds(handler, parent, children, { logInfo = noop, remove = false } = {}) {
|
||||||
if (!Array.isArray(children)) {
|
if (!Array.isArray(children)) {
|
||||||
children = [children]
|
children = [children]
|
||||||
}
|
}
|
||||||
const mergeTargetChild = children.pop()
|
const mergeTargetChild = children.pop()
|
||||||
|
|
||||||
return Promise.all([
|
await VhdAbstract.rename(handler, parent, mergeTargetChild)
|
||||||
VhdAbstract.rename(handler, parent, mergeTargetChild),
|
|
||||||
asyncMap(children, child => {
|
return asyncMap(children, child => {
|
||||||
logInfo(`the VHD child is already merged`, { child })
|
logInfo(`the VHD child is already merged`, { child })
|
||||||
if (remove) {
|
if (remove) {
|
||||||
logInfo(`deleting merged VHD child`, { child })
|
logInfo(`deleting merged VHD child`, { child })
|
||||||
return VhdAbstract.unlink(handler, child)
|
return VhdAbstract.unlink(handler, child)
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
])
|
|
||||||
}
|
}
|
||||||
module.exports._cleanupVhds = cleanupVhds
|
module.exports._cleanupVhds = cleanupVhds
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user