Skip to content

Commit

Permalink
fix(backups): handle undefined remote name in restore description (#8367
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fbeauchamp authored Mar 4, 2025
1 parent 2a2c966 commit cf03313
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions @xen-orchestra/backups/ImportVmBackup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,22 @@ export class ImportVmBackup {
: await importIncrementalVm(backup, await xapi.getRecord('SR', srRef), {
newMacAddresses,
})

const remoteName = adapter._handler._remote.name
let desc = `Restored on ${formatFilenameDate(+new Date())}`
if (remoteName !== undefined) {
desc += ` from ${remoteName}`
}
if (metadata.vm.name_description) {
desc += ` - ${metadata.vm.name_description}`
}
await Promise.all([
xapi.call('VM.add_tags', vmRef, 'restored from backup'),
xapi.call(
'VM.set_name_label',
vmRef,
`${metadata.vm.name_label} (${formatFilenameDate(metadata.timestamp)})`
),
xapi.call(
'VM.set_name_description',
vmRef,
`Restored on ${formatFilenameDate(+new Date())} from ${adapter._handler._remote.name} -
${metadata.vm.name_description}
`
),
xapi.call('VM.set_name_description', vmRef, desc),
])

return {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<!--packages-start-->

- @xen-orchestra/backups patch
- @xen-orchestra/web minor
- xo-server patch

Expand Down

0 comments on commit cf03313

Please sign in to comment.