fix(transcode): co-locate screenshots and derived artifacts in asset storage directory (#399)

* fix(transcode): co-locate screenshots and derived artifacts in asset storage directory

* refactor(transcode): centralize derived artifact directory resolution and strengthen upload assertions
This commit is contained in:
Yiling-J
2026-09-09 11:03:48 +08:00
committed by GitHub
parent 941000d277
commit b37b2172e7
9 changed files with 151 additions and 25 deletions
+16
View File
@@ -34,3 +34,19 @@ export function stemFromKey(key: string): string {
const ext = path.extname(basename)
return ext ? basename.slice(0, -ext.length) : basename
}
/**
* Resolves the parent directory for derived artifacts (e.g. screenshots, proxies, annotations).
* Prefers the directory of the asset's storage key, falling back to `files/<assetId>` if the key
* has no directory prefix.
*
* e.g. 'files/01ABC.../video.mp4' → 'files/01ABC...'
* 'video.mp4' (with assetId '01XYZ...') → 'files/01XYZ...'
*/
export function getDerivedArtifactDirectory(assetKey: string, assetId?: string | null): string {
const dir = path.posix.dirname(assetKey)
if (dir === '.' || !dir) {
return assetId ? `files/${assetId}` : ''
}
return dir
}