-
Notifications
You must be signed in to change notification settings - Fork 775
NIOFileSystem: Add on-disk size to FileInfo #3656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ final class FileInfoTests: XCTestCase { | |
| XCTAssertEqual(info.userID, FileInfo.UserID(rawValue: 5)) | ||
| XCTAssertEqual(info.groupID, FileInfo.GroupID(rawValue: 6)) | ||
| XCTAssertEqual(info.size, 8) | ||
| XCTAssertEqual(info.onDiskSize, 9 * 512) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we maybe add a test case which creates a file with a hole? Should be pretty easy:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an integration regression test that writes hi, resizes the file to 128 MiB, and verifies the logical size while asserting the on-disk allocation remains below 1 MiB. |
||
|
|
||
| XCTAssertEqual(info.lastAccessTime, FileInfo.Timespec(seconds: 0, nanoseconds: 0)) | ||
| XCTAssertEqual(info.lastDataModificationTime, FileInfo.Timespec(seconds: 1, nanoseconds: 0)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakepetroules To avoid an in-flight regression of Windows, can you identify what the appropriate operation is there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the Windows port. The corresponding API for actual allocated bytes is GetCompressedFileSizeW. Because FileInfo currently receives only BY_HANDLE_FILE_INFORMATION while that API is path-based, I need to thread the value through the path/handle information flow and add a Windows sparse-file test rather than add an inaccurate fallback.