feat: 🎸 add file birthTime support - #1277
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds proper birthtime support by introducing a dedicated node creation timestamp (btime) in fs-core and wiring it through to fs-node Stats.birthtime*, with new tests to validate stability across common file operations.
Changes:
- Added
Node.btime(birth/creation time) and included it inNode.toJSON(). - Updated
Stats.build()to reportbirthtime,birthtimeMs, andbirthtimeNsfromNode.btimeinstead ofctime. - Added test coverage in both
fs-core(node-level invariants) andfs-node(stat-level behavior across operations).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/fs-node/src/Stats.ts | Maps Node.btime into Stats.birthtime* (including bigint variants). |
| packages/fs-node/src/tests/birthtime.test.ts | Adds integration tests ensuring birthtime stability across writes/metadata changes and bigint stats. |
| packages/fs-core/src/Node.ts | Introduces btime on nodes and serializes it via toJSON(). |
| packages/fs-core/src/tests/Node.test.ts | Adds unit tests asserting btime initialization and immutability across node mutations. |
Suppressed comments (1)
packages/fs-core/src/Node.ts:363
Node.toJSON()currently reads file contents viagetString(), which updatesatime(and does so twice becausegetString()callsgetBuffer(), which also updatesatime). Serialization shouldn’t have side effects on timestamps; withbtimenow explicitly modeled, this kind of hidden mutation becomes more surprising for snapshot/restore-style uses.
btime: this.btime.getTime(),
perm: this.perm,
mode: this.mode,
nlink: this.nlink,
symlink: this.symlink,
Comment on lines
+34
to
+37
| stats.atime = atime; | ||
| stats.mtime = mtime; | ||
| stats.ctime = ctime; | ||
| stats.birthtime = ctime; | ||
| stats.birthtime = btime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.