(kind: VaultChangeKind)
| 59 | }) |
| 60 | |
| 61 | const handler = (kind: VaultChangeKind) => (absPath: string) => { |
| 62 | const base = path.basename(absPath) |
| 63 | if (!this.root) return |
| 64 | if (isVaultSettingsPath(this.root, absPath)) { |
| 65 | onEvent({ |
| 66 | kind, |
| 67 | path: VAULT_SETTINGS_RELATIVE_PATH, |
| 68 | folder: 'inbox', |
| 69 | scope: 'vault-settings' |
| 70 | }) |
| 71 | return |
| 72 | } |
| 73 | const commentsPath = commentsNotePath(this.root, absPath) |
| 74 | if (commentsPath) { |
| 75 | onEvent({ |
| 76 | kind, |
| 77 | path: commentsPath, |
| 78 | folder: folderForRelativePath(commentsPath) ?? 'inbox', |
| 79 | scope: 'comments' |
| 80 | }) |
| 81 | return |
| 82 | } |
| 83 | // Any database file — `<Name>.base/data.csv` or `schema.json` (or a legacy |
| 84 | // loose `.csv`/sidecar) — normalizes to the canonical `data.csv` path so |
| 85 | // the renderer re-hydrates the right database. (Record-page `.md` notes in |
| 86 | // a `.base` folder return null here and ride the normal note path below.) |
| 87 | const dbCsvPath = databaseCsvPathFor(toPosix(path.relative(this.root, absPath))) |
| 88 | if (dbCsvPath) { |
| 89 | onEvent({ |
| 90 | kind, |
| 91 | path: dbCsvPath, |
| 92 | folder: folderForRelativePath(dbCsvPath) ?? 'inbox', |
| 93 | scope: 'database' |
| 94 | }) |
| 95 | return |
| 96 | } |
| 97 | if (base.startsWith('.')) return |
| 98 | const folder = folderOf(this.root, absPath) |
| 99 | if (!folder) return |
| 100 | onEvent({ |
| 101 | kind, |
| 102 | path: toPosix(path.relative(this.root, absPath)), |
| 103 | folder |
| 104 | }) |
| 105 | } |
| 106 | |
| 107 | // Directory create/remove. An empty folder produces no file event, so |
| 108 | // surface it explicitly — otherwise another client sharing this vault |
no test coverage detected