From a4443b9f4a259a28a6af39f4c24ad436734fcb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Wed, 8 Nov 2023 18:27:14 +0100 Subject: [PATCH] fix(upload): attach response to failed uploads too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- lib/uploader.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/uploader.ts b/lib/uploader.ts index 04b6a925..295c7eb4 100644 --- a/lib/uploader.ts +++ b/lib/uploader.ts @@ -1,4 +1,4 @@ -import { CanceledError } from 'axios' +import { CanceledError, type AxiosError, type AxiosResponse } from 'axios' import { generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import { Folder, Permission } from '@nextcloud/files' @@ -295,6 +295,12 @@ export class Uploader { reject('Upload has been cancelled') return } + + // Attach response to the upload object + if ((error as AxiosError)?.response) { + upload.response = (error as AxiosError).response as AxiosResponse + } + upload.status = UploadStatus.FAILED logger.error(`Failed uploading ${file.name}`, { error, file, upload }) reject('Failed uploading the file')