fix: storage error is not shown

This commit is contained in:
Vasily Zubarev
2025-04-22 13:58:49 +02:00
parent 73e83221b8
commit cfcbfd5445

View File

@@ -12,11 +12,17 @@ import path from "path"
export async function uploadFilesAction(formData: FormData): Promise<ActionState<null>> {
const user = await getCurrentUser()
const files = formData.getAll("files")
const files = formData.getAll("files") as File[]
// Make sure upload dir exists
const userUploadsDirectory = await getUserUploadsDirectory(user)
// Check limits
const totalFileSize = files.reduce((acc, file) => acc + file.size, 0)
if (!isEnoughStorageToUploadFile(user, totalFileSize)) {
return { success: false, error: `Insufficient storage to upload these files` }
}
// Process each file
const uploadedFiles = await Promise.all(
files.map(async (file) => {
@@ -24,10 +30,6 @@ export async function uploadFilesAction(formData: FormData): Promise<ActionState
return { success: false, error: "Invalid file" }
}
if (!isEnoughStorageToUploadFile(user, file.size)) {
return { success: false, error: `Insufficient storage to upload this file: ${file.name}` }
}
// Save file to filesystem
const fileUuid = randomUUID()
const relativeFilePath = await unsortedFilePath(fileUuid, file.name)