MCPcopy Create free account
hub / github.com/CatMuse/HiNote / detectHighlightFilesFromStorage

Function detectHighlightFilesFromStorage

src/storage/HiNoteStorageLayout.ts:21–45  ·  view source on GitHub ↗
(
    app: App,
    vaultPath: string,
    onMappingDetected: (originalPath: string, safeFileName: string) => void
)

Source from the content-addressed store, hash-verified

19}
20
21export async function detectHighlightFilesFromStorage(
22 app: App,
23 vaultPath: string,
24 onMappingDetected: (originalPath: string, safeFileName: string) => void
25): Promise<string[]> {
26 try {
27 const highlightsDir = FilePathUtils.getHighlightsDir(vaultPath);
28 const files = await app.vault.adapter.list(highlightsDir);
29 const detectedFiles: string[] = [];
30
31 for (const file of files.files) {
32 if (!file.endsWith('.json')) continue;
33
34 const baseName = file.replace(/\.json$/, '').replace(highlightsDir + '/', '');
35 const originalPath = FilePathUtils.fromSafeFileName(baseName);
36 detectedFiles.push(originalPath);
37 onMappingDetected(originalPath, baseName);
38 }
39
40 return detectedFiles;
41 } catch (error) {
42 console.warn('扫描高亮目录失败:', error);
43 return [];
44 }
45}

Callers 1

getAllHighlightFilesMethod · 0.90

Calls 3

getHighlightsDirMethod · 0.80
replaceMethod · 0.80
fromSafeFileNameMethod · 0.80

Tested by

no test coverage detected