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
+3 -7
View File
@@ -3,8 +3,9 @@ import { dirname, join } from 'path'
import { mkdir, readdir, readFile, rm, writeFile } from 'fs/promises'
import { existsSync } from 'fs'
import { TMP_DIR } from '@/lib/constants'
import { getModelAssetPath } from '@/lib/model-paths'
import { prepareGitAssets } from '@/lib/prepare-git-assets'
import type { ParsedFile, PreparedAssetSummary } from '@/lib/types'
import type { ParsedFile, PreparedAssetSummary, PushFile } from '@/lib/types'
const STAGING_ROOT = join(TMP_DIR, 'staging')
const STAGING_TTL_MS = 60 * 60 * 1000
@@ -30,11 +31,6 @@ interface StagingManifest {
prepared?: StagedPreparedData
}
interface PushFile {
path: string
contentBase64: string
}
interface PreparedStageAssetsResult {
folderName: string
filesToPush: PushFile[]
@@ -148,7 +144,7 @@ async function buildPreparedPushFiles(stagingId: string, manifest: StagingManife
manifest.originals.map(async (file) => {
const buffer = await readFile(join(preparedDir, file.filename))
return {
path: `public/models/${manifest.folderName}/${file.filename}`,
path: getModelAssetPath(manifest.folderName, file.filename),
contentBase64: buffer.toString('base64'),
}
}),