同步处理
This commit is contained in:
1 parent
9939943e31
commit
6494ad2918
26 files changed
+970
-40
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { requireSiteSyncAuth } from '../../utils/access'
|
||||
import { createApiError } from '../../utils/api-error'
|
||||
import { validateStorageKey } from '../../utils/image-key'
|
||||
import { finalizeSiteSyncChunk } from '../../utils/site-sync/chunks'
|
||||
|
||||
interface Body {
|
||||
jobId?: string
|
||||
key?: string
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireSiteSyncAuth(event)
|
||||
const body = await readBody<Body>(event).catch(() => null)
|
||||
const jobId = body?.jobId?.trim() ?? ''
|
||||
const key = body?.key?.trim() ?? ''
|
||||
if (!jobId || !validateStorageKey(key)) {
|
||||
createApiError(event, 'INVALID_REQUEST', '分块完成参数无效', 400)
|
||||
}
|
||||
try {
|
||||
return await finalizeSiteSyncChunk({ jobId, key })
|
||||
} catch (error) {
|
||||
createApiError(
|
||||
event,
|
||||
'INVALID_REQUEST',
|
||||
error instanceof Error ? error.message : '分块组装失败',
|
||||
400
|
||||
)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user