refactor: consolidate upload helpers
This commit is contained in:
@@ -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'),
|
||||
}
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user