diff --git a/apps/ignis-server/server/routes/fs.js b/apps/ignis-server/server/routes/fs.js index e547ab6..10ddb3e 100644 --- a/apps/ignis-server/server/routes/fs.js +++ b/apps/ignis-server/server/routes/fs.js @@ -392,22 +392,6 @@ router.get("/access", async (req, res) => { } }); -router.get("/realpath", async (req, res) => { - const resolved = guardPath(req, res); - - if (!resolved) { - return; - } - - try { - const real = await fs.promises.realpath(resolved); - - res.json({ path: path.relative(req._vaultRoot, real) }); - } catch (e) { - res.status(500).json({ error: e.code || "internal", code: e.code }); - } -}); - // POST /api/fs/utimes { path, atime, mtime, vault? } router.post("/utimes", async (req, res) => { const resolved = guardPath(req, res, "body"); diff --git a/packages/shim/src/fs/promises.js b/packages/shim/src/fs/promises.js index 7b059aa..391ed3a 100644 --- a/packages/shim/src/fs/promises.js +++ b/packages/shim/src/fs/promises.js @@ -6,6 +6,7 @@ import { resolvePath, } from "./transforms.js"; import { hasVirtualFile, getVirtualFile } from "./virtual-files.js"; +import { realpathSync } from "./realpath.js"; export function createFsPromises(metadataCache, contentCache, transport) { return { @@ -260,7 +261,8 @@ export function createFsPromises(metadataCache, contentCache, transport) { return "/"; } - return transport.realpath(path); + // No symlinks in the vault FS, so realpath is the identity. + return realpathSync(path); }, async utimes(path, atime, mtime) { diff --git a/packages/shim/src/fs/realpath.test.js b/packages/shim/src/fs/realpath.test.js index bc3c9eb..a5cbed3 100644 --- a/packages/shim/src/fs/realpath.test.js +++ b/packages/shim/src/fs/realpath.test.js @@ -1,5 +1,6 @@ import { describe, it, expect } from "vitest"; import { realpath } from "./realpath.js"; +import { createFsPromises } from "./promises.js"; describe("fs realpath shim", () => { it("realpath invokes the callback with the path", async () => { @@ -18,3 +19,18 @@ describe("fs realpath shim", () => { expect(result).toBe("/a/b.md"); }); }); + +describe("fs.promises realpath", () => { + it("answers locally without touching the transport", async () => { + const fs = createFsPromises({}, {}, {}); + + expect(await fs.realpath("/a/b.md")).toBe("/a/b.md"); + }); + + it("maps empty and root paths to /", async () => { + const fs = createFsPromises({}, {}, {}); + + expect(await fs.realpath("")).toBe("/"); + expect(await fs.realpath(".")).toBe("/"); + }); +}); diff --git a/packages/shim/src/fs/transport.js b/packages/shim/src/fs/transport.js index 1298720..1975d9e 100644 --- a/packages/shim/src/fs/transport.js +++ b/packages/shim/src/fs/transport.js @@ -177,13 +177,6 @@ export const transport = { return requestJson("GET", "/access", { path: normPath(path) }); }, - async realpath(path) { - const result = await requestJson("GET", "/realpath", { - path: normPath(path), - }); - return result.path; - }, - async utimes(path, atime, mtime) { return requestJson("POST", "/utimes", { path: normPath(path),