Skip to content

RNMT-9 fix: use Long for offset to support files larger than 2.14GB - #10

Open
anfuerer wants to merge 4 commits into
ionic-team:mainfrom
anfuerer:issue/chunking-files-larger-2.14gb
Open

RNMT-9 fix: use Long for offset to support files larger than 2.14GB#10
anfuerer wants to merge 4 commits into
ionic-team:mainfrom
anfuerer:issue/chunking-files-larger-2.14gb

Conversation

@anfuerer

Copy link
Copy Markdown

Description

Change offset parameter type from Int to Long in IONFILEReadOptions and IONFILEReadInChunksOptions to fix file corruption when reading files larger than 2.14GB using chunking.

Context

When reading files larger than ~2.14GB (Int.MAX_VALUE bytes), the Int offset would overflow, causing incorrect seek positions and corrupt reads. Changing offset to Long allows addressing positions beyond the 2.14GB boundary.

Type of changes

  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android

Tests

Added a test in IONFILELocalFilesHelperTest that creates a sparse file larger than 2GB (no actual disk allocation), writes known content at an offset beyond Int.MAX_VALUE, and verifies that readFileInChunks returns the correct content when called with that offset.

Checklist

  • Pull request title follows the format RNMT-XXXX <title>
  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

anfuerer added 3 commits March 10, 2026 22:35
Change offset from Int to Long in IONFILEReadInChunksOptions and
IONFILEReadOptions to prevent integer overflow when reading files
beyond the ~2.14GB Int.MAX_VALUE boundary.
Uses a sparse file (no actual 2GB+ disk allocation) to test that reading
with an offset beyond Int.MAX_VALUE returns the correct content.
@anfuerer

Copy link
Copy Markdown
Author

@OS-pedrogustavobilro would you mind having a look at this PR?

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.

1 participant