MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / allocateAssetPath

Function allocateAssetPath

apps/desktop/src/main/ipc/runtime-fs.ts:50–62  ·  view source on GitHub ↗
(
  files: Map<string, string>,
  request: GenerateImageAssetRequest,
  mimeType: string,
)

Source from the content-addressed store, hash-verified

48}
49
50export function allocateAssetPath(
51 files: Map<string, string>,
52 request: GenerateImageAssetRequest,
53 mimeType: string,
54): string {
55 const stem = sanitizeAssetStem(request.filenameHint, request.purpose);
56 const ext = extensionFromMimeType(mimeType);
57 let path = `assets/${stem}.${ext}`;
58 for (let i = 2; files.has(path); i++) {
59 path = `assets/${stem}-${i}.${ext}`;
60 }
61 return path;
62}
63
64interface CreateRuntimeTextEditorFsOptions {
65 db: Database | null;

Callers 1

runGenerateFunction · 0.90

Calls 2

sanitizeAssetStemFunction · 0.85
extensionFromMimeTypeFunction · 0.85

Tested by

no test coverage detected