feat(file): optimize upload and transcoding status polling with batch api (#512)

* feat(file): optimize upload and transcoding status polling with batch api

* fix(webui): throttle search invalidation during upload and fix stuck 100% progress ring

* fix(webui): deduplicate upload search invalidation and stabilize batch polling
This commit is contained in:
Yiling-J
2026-10-31 20:11:31 +08:00
committed by GitHub
parent c2348b0e68
commit fbff404b9b
11 changed files with 541 additions and 58 deletions
+35
View File
@@ -14,6 +14,7 @@ import {
import {
createCommentRequestSchema,
deleteFilesRequestSchema,
batchGetFilesRequestSchema,
paginationParamsSchema,
restoreFilesRequestSchema,
updateAssetMetadataRequestSchema,
@@ -39,6 +40,40 @@ import { z } from 'zod'
type User = Prisma.UserGetPayload<Record<string, never>>
const route = new Hono<{ Variables: { user: User } }>()
.post('/files/batch', zValidator('json', batchGetFilesRequestSchema), async (c) => {
const user = c.get('user')
const req = c.req.valid('json')
if (req.ids.length === 0) {
return c.json([])
}
const accessibleIds: string[] = []
await Promise.all(
req.ids.map(async (id) => {
try {
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Asset,
id,
})
accessibleIds.push(id)
} catch {
// Permissive: silently ignore missing or unauthorized IDs
}
}),
)
if (accessibleIds.length === 0) {
return c.json([])
}
const accessibleSet = new Set(accessibleIds)
const orderedAccessibleIds = req.ids.filter((id) => accessibleSet.has(id))
const assets = await assetService.listAssetsByIds(orderedAccessibleIds)
return c.json(assets)
})
.get('/files/:fileId', async (c) => {
const fileId = c.req.param('fileId')
const user = c.get('user')