refactor: consolidate upload helpers

This commit is contained in:
Tom Boullay
2026-04-27 17:20:54 +02:00
parent 43cf48cc7d
commit d049318a73
11 changed files with 38 additions and 38 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from 'next/server'
import { validateUploadSecret } from '@/lib/auth'
import { getRemoteFolder } from '@/lib/github'
import { classifyFileChanges } from '@/lib/diff-files'
import { getModelFolderPath } from '@/lib/model-paths'
import { ensurePreparedStagingAssets } from '@/lib/upload-staging'
export const runtime = 'nodejs'
@@ -30,7 +31,7 @@ export async function POST(req: NextRequest) {
try {
const { folderName, filesToPush } = await ensurePreparedStagingAssets(stagingId)
const folderPath = `public/models/${folderName}`
const folderPath = getModelFolderPath(folderName)
const { exists, files } = await getRemoteFolder(folderPath)
if (exists) {
+2 -1
View File
@@ -3,6 +3,7 @@ import { validateUploadSecret } from '@/lib/auth'
import { getRemoteFolder, pushAllToGitHub } from '@/lib/github'
import { buildCommitMessage } from '@/lib/commit-message'
import { classifyFileChanges } from '@/lib/diff-files'
import { getModelFolderPath } from '@/lib/model-paths'
import { cleanupStagingUpload, ensurePreparedStagingAssets, readStagedManifest } from '@/lib/upload-staging'
import { acquireUploadLock, releaseUploadLock } from '@/lib/upload-lock'
@@ -52,7 +53,7 @@ export async function POST(req: NextRequest) {
} = await ensurePreparedStagingAssets(stagingId)
// --- Detect existing files and classify changes ---
const folderPath = `public/models/${folderName}`
const folderPath = getModelFolderPath(folderName)
let remoteFileMap: Map<string, number>
try {