mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-14 04:55:27 +00:00
feat: calculate used storage
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
import { ActionState } from "@/lib/actions"
|
||||
import { getCurrentUser } from "@/lib/auth"
|
||||
import { getUserUploadsDirectory, unsortedFilePath } from "@/lib/files"
|
||||
import { getDirectorySize, getUserUploadsDirectory, unsortedFilePath } from "@/lib/files"
|
||||
import { createFile } from "@/models/files"
|
||||
import { updateUser } from "@/models/users"
|
||||
import { randomUUID } from "crypto"
|
||||
import { mkdir, writeFile } from "fs/promises"
|
||||
import { revalidatePath } from "next/cache"
|
||||
@@ -50,6 +51,10 @@ export async function uploadFilesAction(formData: FormData): Promise<ActionState
|
||||
})
|
||||
)
|
||||
|
||||
// Update user storage used
|
||||
const storageUsed = await getDirectorySize(await getUserUploadsDirectory(user))
|
||||
await updateUser(user.id, { storageUsed })
|
||||
|
||||
console.log("uploadedFiles", uploadedFiles)
|
||||
|
||||
revalidatePath("/unsorted")
|
||||
|
||||
Reference in New Issue
Block a user