MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / indexContentFolder

Function indexContentFolder

src/shared/curate/util.ts:39–55  ·  view source on GitHub ↗
(contentPath: string, log: (content: string) => void)

Source from the content-addressed store, hash-verified

37 * @param log Log function to use for errors
38 */
39export async function indexContentFolder(contentPath: string, log: (content: string) => void): Promise<IndexedContent[]> {
40 const content: IndexedContent[] = [];
41 await access(contentPath, fs.constants.F_OK)
42 .then(() => {
43 return recursiveFolderIndex(contentPath, contentPath, content)
44 .catch((error) => {
45 log('Error indexing folder - ' + error.message);
46 console.error(error);
47 });
48 })
49 .catch(() => {
50 const msg = `Content folder given doesn't exist, skipping... (${contentPath})`;
51 log(msg);
52 console.log(msg);
53 });
54 return content;
55}
56
57export async function recursiveFolderIndex(folderPath: string, basePath: string, content: IndexedContent[]): Promise<void> {
58 // List all sub-files (and folders)

Callers

nothing calls this directly

Calls 1

recursiveFolderIndexFunction · 0.85

Tested by

no test coverage detected