Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib/synced-state-location.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/synced-state-location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Loading