Compare commits

..

1 Commits

Author SHA1 Message Date
Florent BEAUCHAMP
f51e25ac28 fix(XenApi): cannot read properties of undefined (reading 'statusCode') 2023-08-29 08:48:40 +02:00
4 changed files with 7 additions and 21 deletions

View File

@@ -683,17 +683,11 @@ export class RemoteAdapter {
async outputStream(path, input, { checksum = true, validator = noop } = {}) {
const container = watchStreamSize(input)
const handler = this._handler
await handler.outputStream(path, input, {
await this._handler.outputStream(path, input, {
checksum,
dirMode: this._dirMode,
async validator(tmpPath) {
async validator() {
await input.task
// size on file system can be bigger when encrypted ( IV + alignment padding)
const size = await handler.getSize(tmpPath, { exact: false })
if (Math.abs(size - container.size) > handler.getSizeApproximationMargin()) {
return false
}
return validator.apply(this, arguments)
},
})

View File

@@ -227,19 +227,11 @@ export default class RemoteHandlerAbstract {
// when using encryption, the file size is aligned with the encryption block size ( 16 bytes )
// that means that the size will be 1 to 16 bytes more than the content size + the initialized vector length (16 bytes)
async getSize(file, { exact = true } = {}) {
exact && assert.strictEqual(this.isEncrypted, false, `Can't compute size of an encrypted file ${file}`)
async getSize(file) {
assert.strictEqual(this.isEncrypted, false, `Can't compute size of an encrypted file ${file}`)
const size = await timeout.call(this._getSize(typeof file === 'string' ? normalizePath(file) : file), this._timeout)
return size
}
getSizeApproximationMargin() {
if (this.isEncrypted) {
// on block for initialization vector + at most 1 bloc - 1 byte for aligment padding
return this.#encryptor.ivLength * 2 - 1
}
return 0
return size - this.#encryptor.ivLength
}
async __list(dir, { filter, ignoreMissing = false, prependDir = false } = {}) {

View File

@@ -10,7 +10,6 @@
- [Netbox] Synchronize VM tags [#5899](https://github.com/vatesfr/xen-orchestra/issues/5899) [Forum#6902](https://xcp-ng.org/forum/topic/6902) (PR [#6957](https://github.com/vatesfr/xen-orchestra/pull/6957))
- [REST API] Add support for `filter` and `limit` parameters to `backups/logs` and `restore/logs` collections [Forum#64789](https://xcp-ng.org/forum/post/64789)
- [Pool/Advanced] Ability to set a crash dump SR [#5060](https://github.com/vatesfr/xen-orchestra/issues/5060) (PR [#6973](https://github.com/vatesfr/xen-orchestra/pull/6973))
- [Backup/full] Ensure full xva is written (PR [#7005](https://github.com/vatesfr/xen-orchestra/pull/7005))
### Bug fixes
@@ -22,6 +21,7 @@
- [Home/VMs] Filtering with a UUID will no longer show other VMs on the same host/pool
- [Jobs] Fixes `invalid parameters` when editing [Forum#64668](https://xcp-ng.org/forum/post/64668)
- [Smart reboot] Fix cases where VMs remained in a suspended state (PR [#6980](https://github.com/vatesfr/xen-orchestra/pull/6980))
- [XenApi/stats] Fix `Cannot read properties of undefined (reading 'statusCode')` (PR [#7004](https://github.com/vatesfr/xen-orchestra/pull/7004))
### Packages to release

View File

@@ -419,7 +419,7 @@ export class Xapi extends EventEmitter {
signal: $cancelToken,
}),
{
when: error => error.response !== undefined && error.response.statusCode === 302,
when: error => error.response !== undefined && error.response?.statusCode === 302,
onRetry: async error => {
const response = error.response
if (response === undefined) {