Skip to content

feat: Add onDiskSize property to FileInfo (Fixes #3650) - #3668

Closed
wasim-builds wants to merge 2 commits into
apple:mainfrom
wasim-builds:fix/issue-3650-ondisksize
Closed

feat: Add onDiskSize property to FileInfo (Fixes #3650)#3668
wasim-builds wants to merge 2 commits into
apple:mainfrom
wasim-builds:fix/issue-3650-ondisksize

Conversation

@wasim-builds

Copy link
Copy Markdown
Contributor

Hey @weissi! 👋

As discussed in #3650, I've added the .onDiskSize property to FileInfo to accurately report the actual size used on disk (accounting for holes in sparse files and APFS compression).

Implementation Details:

  • Implemented Int64(platformSpecificStatus.st_blocks) * 512 for POSIX systems (Linux/Darwin) using the POSIX standard block size of 512 bytes.
  • Safely defaults to nil on Windows where st_blocks is unavailable.
  • Added tests to FileInfoTests.swift verifying the block multiplication.
  • Carefully updated the initializers using default arguments (onDiskSize: Int64? = nil) to ensure we do not break the existing public API.

All unit tests are passing locally. Let me know if you'd like any modifications, otherwise this should be good to merge! 🚀

@glbrntt

glbrntt commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Closing as there's already an open PR for this: #3656

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants