Skip to content

Commit 99923fe

Browse files
authored
Merge pull request #2867 from appwrite/fix/site-upload-invalid-reason
Fix generic invalid file error in site manual upload
2 parents 562a6bc + 391adec commit 99923fe

6 files changed

Lines changed: 48 additions & 41 deletions

File tree

bun.lock

Lines changed: 23 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"vitest": "^3.2.4"
8989
},
9090
"overrides": {
91-
"vite": "npm:rolldown-vite@latest"
91+
"vite": "npm:rolldown-vite@latest",
92+
"minimatch": "10.2.1"
9293
}
9394
}

src/lib/actions/portal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Action } from 'svelte/action';
33

44
export type PortalConfig = string | HTMLElement | undefined;
55

6-
export const portal: Action<HTMLElement, PortalConfig> = (el, target = 'body') => {
6+
export const portal: Action<HTMLElement, PortalConfig> = (el, target: PortalConfig = 'body') => {
77
let targetEl;
88

99
async function update(newTarget: PortalConfig) {
@@ -17,7 +17,7 @@ export const portal: Action<HTMLElement, PortalConfig> = (el, target = 'body') =
1717
if (targetEl === null) {
1818
throw new Error(`No element found matching css selector: "${target}"`);
1919
}
20-
} else if (target instanceof HTMLElement) {
20+
} else if (typeof target === 'object' && target instanceof HTMLElement) {
2121
targetEl = target;
2222
} else {
2323
throw new TypeError(

src/lib/actions/tooltip.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Action } from 'svelte/action';
2+
import type { Instance } from 'tippy.js';
23
import type { Props as TippyProps } from 'tippy.js';
34
import tippy from 'tippy.js';
45

@@ -7,7 +8,8 @@ type Props = TippyProps & {
78
};
89

910
export const tooltip: Action<HTMLElement, Partial<Props>> = (node, config) => {
10-
const instance = tippy(node, config);
11+
const tippyInstance = tippy(node, config);
12+
const instance: Instance = Array.isArray(tippyInstance) ? tippyInstance[0] : tippyInstance;
1113
if (config.disabled) instance.disable();
1214

1315
return {

src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,22 @@
138138
}
139139
140140
function handleInvalid(e: CustomEvent) {
141-
const reason = e.detail?.reason ?? '';
141+
let reason = e.detail?.reason ?? '';
142+
143+
if (!reason) {
144+
const nativeEvent = e.detail as Event | undefined;
145+
const input = (nativeEvent?.currentTarget ?? nativeEvent?.target) as
146+
| HTMLInputElement
147+
| undefined;
148+
const pickedFiles = Array.from(input?.files ?? []);
149+
150+
if (pickedFiles.some((file) => file.size > maxSize)) {
151+
reason = InvalidFileType.SIZE;
152+
} else if (pickedFiles.some((file) => !file.name.toLowerCase().endsWith('.tar.gz'))) {
153+
reason = InvalidFileType.EXTENSION;
154+
}
155+
}
156+
142157
if (reason === InvalidFileType.EXTENSION) {
143158
addNotification({
144159
type: 'error',
@@ -147,7 +162,7 @@
147162
} else if (reason === InvalidFileType.SIZE) {
148163
addNotification({
149164
type: 'error',
150-
message: 'File size exceeds 10MB'
165+
message: `File size exceeds ${readableMaxSize.value}${readableMaxSize.unit}`
151166
});
152167
} else {
153168
addNotification({

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vite';
1+
import { defineConfig } from 'vitest/config';
22
import { sveltekit } from '@sveltejs/kit/vite';
33
import { sentrySvelteKit } from '@sentry/sveltekit';
44
import { svelteTesting } from '@testing-library/svelte/vite';

0 commit comments

Comments
 (0)