mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 22:15:33 +00:00
refactor(shared-manager): tighten canonical identity capture
Build the canonical identity from the stat getCanonicalFile already takes, instead of a second lstat of the same inode. One syscall less, and mode, mtime and identity now describe the same moment rather than two adjacent ones. Assert in the adoption race tests that the foreign writer never fired. It writes only when the canonical path is observed empty, so a zero count states the invariant the fix establishes - the path is never left without a regular file - instead of only checking the final content. Built [OnSteroids](https://onsteroids.ai)
This commit is contained in:
1 parent
00a4dceb94
commit
fa3fd8eb3a
2 files changed
+10
-10
No files matched your search
@@ -686,6 +686,10 @@ describe('SharedManager', () => {
|
||||
foreignWriter.restore();
|
||||
}
|
||||
|
||||
// The writer only fires when the canonical path is observed empty, so
|
||||
// zero writes is the invariant itself: adoption never left the path
|
||||
// without a regular file.
|
||||
expect(foreignWriter.placeholderWrites()).toBe(0);
|
||||
expect(fs.existsSync(canonicalPath)).toBe(true);
|
||||
expect(fs.readFileSync(canonicalPath, 'utf8')).not.toBe(placeholder);
|
||||
expect([divergedSettings, previousSettings]).toContainEqual(readJson(canonicalPath));
|
||||
|
||||
Reference in new issue
Block a user