mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
feat(media-use): v2 media OS core (resolve cascade, providers, local generation, telemetry) + retire hyperframes-media
This commit is contained in:
@@ -29,8 +29,12 @@ function markComplete(entryDir) {
|
||||
writeFileSync(join(entryDir, COMPLETE_SENTINEL), "", "utf8");
|
||||
}
|
||||
|
||||
// The manifest helpers append their own ".media" to the dir they get, so the
|
||||
// global manifest must be addressed by HOME, not by globalMediaDir() — passing
|
||||
// the latter nested it at ~/.media/.media/manifest.jsonl, invisible to the
|
||||
// Studio /api/assets/global route (which reads the documented flat path).
|
||||
function readGlobalManifest() {
|
||||
return readManifest(globalMediaDir());
|
||||
return readManifest(homedir());
|
||||
}
|
||||
|
||||
function validateCacheHit(match) {
|
||||
@@ -55,6 +59,11 @@ export function cacheGetByEntity(entity) {
|
||||
|
||||
export function cachePut(filePath, record) {
|
||||
const sha = contentHash(filePath);
|
||||
// Idempotent: same content already promoted -> don't duplicate the global
|
||||
// record. ponytail: skips usage_count bump; add it when the metric is needed.
|
||||
const existing = readGlobalManifest().find((r) => r.sha === sha);
|
||||
if (existing) return { sha, cached_path: existing.cached_path, deduped: true };
|
||||
|
||||
const dir = globalMediaDir();
|
||||
const entryDir = cacheEntryDir(dir, sha);
|
||||
mkdirSync(entryDir, { recursive: true });
|
||||
@@ -69,7 +78,7 @@ export function cachePut(filePath, record) {
|
||||
reusable: true,
|
||||
cached_path: dest,
|
||||
};
|
||||
appendRecord(globalMediaDir(), globalRecord);
|
||||
appendRecord(homedir(), globalRecord);
|
||||
return { sha, cached_path: dest };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user