(path: string, depth = 0)
| 394 | // ── Symlink resolution ──────────────────────────────────────── |
| 395 | |
| 396 | private async resolveSymlink(path: string, depth = 0): Promise<string> { |
| 397 | if (depth > MAX_SYMLINK_DEPTH) { |
| 398 | throw new Error(`ELOOP: too many levels of symbolic links: ${path}`); |
| 399 | } |
| 400 | const T = this.tableName; |
| 401 | const rows = await this.sql.query<{ |
| 402 | type: string; |
| 403 | target: string | null; |
| 404 | }>(`SELECT type, target FROM ${T} WHERE path = ?`, path); |
| 405 | const r = rows[0]; |
| 406 | if (!r || r.type !== "symlink" || !r.target) return path; |
| 407 | const resolved = r.target.startsWith("/") |
| 408 | ? normalizePath(r.target) |
| 409 | : normalizePath(getParent(path) + "/" + r.target); |
| 410 | return this.resolveSymlink(resolved, depth + 1); |
| 411 | } |
| 412 | |
| 413 | // ── Symlink API ─────────────────────────────────────────────── |
| 414 |
no test coverage detected