From 91be3f1d8214d00ef5558e849d1a7bcdea7fe2b1 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 20 Feb 2026 11:43:50 +0530 Subject: [PATCH] Fix site upload invalid event reason handling --- .../sites/create-site/manual/+page.svelte | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte index ab35e9d67..f366e0a4f 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte @@ -138,7 +138,22 @@ } function handleInvalid(e: CustomEvent) { - const reason = e.detail?.reason ?? ''; + let reason = e.detail?.reason ?? ''; + + if (!reason) { + const nativeEvent = e.detail as Event | undefined; + const input = (nativeEvent?.currentTarget ?? nativeEvent?.target) as + | HTMLInputElement + | undefined; + const pickedFiles = Array.from(input?.files ?? []); + + if (pickedFiles.some((file) => file.size > maxSize)) { + reason = InvalidFileType.SIZE; + } else if (pickedFiles.some((file) => !file.name.toLowerCase().endsWith('.tar.gz'))) { + reason = InvalidFileType.EXTENSION; + } + } + if (reason === InvalidFileType.EXTENSION) { addNotification({ type: 'error', @@ -147,7 +162,7 @@ } else if (reason === InvalidFileType.SIZE) { addNotification({ type: 'error', - message: 'File size exceeds 10MB' + message: `File size exceeds ${readableMaxSize.value}${readableMaxSize.unit}` }); } else { addNotification({