diff --git a/src/lib/synced-state-location.ts b/src/lib/synced-state-location.ts index 21b4bae24fb..1da04f759c7 100644 --- a/src/lib/synced-state-location.ts +++ b/src/lib/synced-state-location.ts @@ -1,6 +1,11 @@ import { lstatSync, realpathSync } from "node:fs"; import { homedir } from "node:os"; -import { join, resolve } from "node:path"; +// POSIX path operations on purpose: every path this module classifies is a macOS path. The +// host's own path module would build backslash or drive-letter paths on Windows and make the +// injected-platform tests compare different strings there (dev CI windows 5/9 after #6398). +import { posix } from "node:path"; + +const { join, resolve } = posix; /** * Where a state directory sits relative to the folders macOS keeps in sync with a cloud. diff --git a/tests/lib/synced-state-location.test.ts b/tests/lib/synced-state-location.test.ts index 6811249ef0d..5b157471d08 100644 --- a/tests/lib/synced-state-location.test.ts +++ b/tests/lib/synced-state-location.test.ts @@ -64,4 +64,17 @@ describe("synced state directory detection (#6314)", () => { expect(text).not.toContain("/Users/"); } }); + + test("classification uses macOS path rules whatever host runs it", () => { + // The probe says darwin while this may run on Windows: no separator or drive-letter handling + // from the host may reach the paths being compared. + const seen: string[] = []; + const entryExists = (path: string): boolean => { + seen.push(path); + return desktopDocumentsSynced(path); + }; + expect(syncedStateLocation(`${HOME}/Documents/state`, probe({ entryExists }))).toBe("icloud-desktop-documents"); + expect(seen.length).toBeGreaterThan(0); + expect(seen.every((path) => path.startsWith(`${HOME}/`) && !path.includes("\\"))).toBe(true); + }); });