mirror of
https://github.com/vas3k/TaxHacker.git
synced 2026-01-05 05:01:09 -06:00
fix: storage error is not shown
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user