diff --git a/frontend/src/components/object/ObjectUpload.vue b/frontend/src/components/object/ObjectUpload.vue index 2cbdc234..7b566ba1 100644 --- a/frontend/src/components/object/ObjectUpload.vue +++ b/frontend/src/components/object/ObjectUpload.vue @@ -63,16 +63,10 @@ const onUpload = async (event: any) => { ); successfulFiles.value.push(file); } catch (error: any) { - // show toasts - if (error?.response?.status === 409) { - toast.error(`Failed to upload file ${file.name}`, 'File already exists'); - } else { - toast.error(`Failed to upload file ${file.name}`, error); - } + toast.error(`Failed to upload file ${file.name}`, error, {life: 0}); failedFiles.value.push(file); } finally { appStore.endUploading(); - appStore.endIndeterminateLoading(); } }) ); diff --git a/frontend/src/store/objectStore.ts b/frontend/src/store/objectStore.ts index 0ae5cff1..4f7fee81 100644 --- a/frontend/src/store/objectStore.ts +++ b/frontend/src/store/objectStore.ts @@ -51,17 +51,28 @@ export const useObjectStore = defineStore('object', () => { }, axiosOptions?: AxiosRequestConfig ) { - appStore.beginIndeterminateLoading(); - - // Ensure x-amz-meta- prefix exists - if (headers.metadata) { - for (const meta of headers.metadata) { - if (!meta.key.startsWith('x-amz-meta-')) { - meta.key = `x-amz-meta-${meta.key}`; + try{ + appStore.beginIndeterminateLoading(); + // Ensure x-amz-meta- prefix exists + if (headers.metadata) { + for (const meta of headers.metadata) { + if (!meta.key.startsWith('x-amz-meta-')) { + meta.key = `x-amz-meta-${meta.key}`; + } } } + await objectService.createObject(object, headers, params, axiosOptions); + } + catch(error: any){ + if (error.response?.status === 409){ + throw new Error(error.response.data.detail); + } else { + throw new Error('Network error'); + } + } + finally{ + appStore.endIndeterminateLoading(); } - await objectService.createObject(object, headers, params, axiosOptions); } async function deleteObject(objectId: string, versionId?: string) { diff --git a/frontend/tests/unit/store/objectStore.spec.ts b/frontend/tests/unit/store/objectStore.spec.ts index 99d465ed..25351022 100644 --- a/frontend/tests/unit/store/objectStore.spec.ts +++ b/frontend/tests/unit/store/objectStore.spec.ts @@ -113,6 +113,7 @@ describe('Object Store', () => { }, { timeout: 0 } ); + expect(endIndeterminateLoadingSpy).toHaveBeenCalledTimes(1); }); });