Skip to content

Commit

Permalink
fix(xo-server/rest-api): fix broken VDI export
Browse files Browse the repository at this point in the history
Introduced by 7b256ab

Not completely fixed by 8eae8e7

See zammad#27167
  • Loading branch information
julien-f committed Sep 17, 2024
1 parent b8388bb commit aa490dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Hub/Recipes/Kubernetes] Properly sort versions in selector
- [Host/Network] Fix `an error has occurred` briefly displaying in 'Mode' column of the host's Network tab (PR [#7954](https://github.com/vatesfr/xen-orchestra/pull/7954))
- [REST API] Fix VDI export broken in XO 5.96.0 and not completely fixed in XO 5.98.0

### Packages to release

Expand All @@ -41,6 +42,7 @@
- @xen-orchestra/lite minor
- @xen-orchestra/web minor
- @xen-orchestra/web-core minor
- xo-server patch
- xo-web minor

<!--packages-end-->
9 changes: 8 additions & 1 deletion packages/xo-server/src/xo-mixins/rest-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,14 @@ export default class RestApi {
const nbdConcurrency = req.query.nbdConcurrency && parseInt(req.query.nbdConcurrency)
const stream = await req.xapiObject.$exportContent({ format: req.params.format, preferNbd, nbdConcurrency })

res.writeHead(200, 'OK', { 'content-disposition': 'attachment', 'content-length': stream.length })
const headers = { 'content-disposition': 'attachment' }

const { length } = stream
if (length !== undefined) {
headers['content-length'] = length
}

res.writeHead(200, 'OK', headers)
await pipeline(stream, res)
})
)
Expand Down

0 comments on commit aa490dc

Please sign in to comment.