mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
feat: implement storage quota management for uploads
- Added storage quota enforcement for audio and image uploads in the respective routes. - Introduced reservation system to manage concurrent uploads and prevent quota overages. - Enhanced comment creation to account for audio and image attachment sizes against user quotas. - Created new UploadReservation model to track in-flight upload reservations. - Backfilled existing video assets with size information from R2. - Added progress component for UI feedback during uploads. - Updated API responses to include reservation IDs for better quota management. - Adjusted error handling to return appropriate storage limit exceeded messages.
This commit is contained in:
@@ -399,6 +399,7 @@ model VideoAsset {
|
||||
uploadedByGuestName String?
|
||||
billedUserId String
|
||||
billedUser User @relation("VideoAssetBilledTo", fields: [billedUserId], references: [id], onDelete: Cascade)
|
||||
sizeBytes BigInt @default(0) @map("size_bytes")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -687,6 +688,19 @@ model WatchProgress {
|
||||
@@map("watch_progress")
|
||||
}
|
||||
|
||||
// Tracks in-flight R2 upload slots so concurrent uploads are counted against quota
|
||||
// before the VideoAsset record is committed. Rows expire after a short TTL.
|
||||
model UploadReservation {
|
||||
id String @id @default(cuid())
|
||||
billedUserId String
|
||||
sizeBytes BigInt
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([billedUserId, expiresAt])
|
||||
@@map("upload_reservations")
|
||||
}
|
||||
|
||||
// Rate limiting table (created as UNLOGGED via raw SQL migration)
|
||||
// Defined here so `prisma db push` doesn't drop it
|
||||
model RateLimit {
|
||||
|
||||
Reference in New Issue
Block a user