Skip to content
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

[NIOFileSystem] Provide an API to specify allowing unlimited sized reads #2914

Conversation

clintonpi
Copy link
Contributor

Motivation:

As described in issue #2877, there is no API available to specify allowing a read of unlimited size.

Modifications:

  • Add a new public static property, unlimited, to ByteCount representing an unlimited amount of bytes.
  • Adapt ReadableFileHandleProtocol.readToEnd(fromAbsoluteOffset:maximumSizeAllowed:) to work with maximumSizeAllowed being ByteCount.unlimited.

Result:

An API to specify allowing a read of an unlimited size will be available.

Motivation:

As described in issue [apple#2877](apple#2877), there is no API available to specify allowing a read of unlimited size.

Modifications:

- Add a new `public static` property, `unlimited`, to `ByteCount` representing an unlimited amount of bytes.
- Adapt `ReadableFileHandleProtocol.readToEnd(fromAbsoluteOffset:maximumSizeAllowed:)` to work with `maximumSizeAllowed` being `ByteCount.unlimited`.

Result:

An API to specify allowing a read of an unlimited size will be available.
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit but looks great otherwise

Comment on lines 338 to 341
var maximumSizeAllowed = maximumSizeAllowed
if maximumSizeAllowed == .unlimited {
maximumSizeAllowed = .byteBufferCapacity
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this in a one line to keep maximumSizeAllowed constant:

let maximumSizeAllowed = maximumSizeAllowed == .unlimited ? .byteBufferCapacity : maximumSizeAllowed

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Oct 11, 2024
@clintonpi clintonpi requested a review from glbrntt October 11, 2024 08:30
@glbrntt glbrntt enabled auto-merge (squash) October 11, 2024 08:31
@glbrntt glbrntt merged commit 17ebfcd into apple:main Oct 11, 2024
28 of 29 checks passed
@clintonpi clintonpi deleted the provide-api-to-specify-allowing-unlimited-sized-reads branch October 11, 2024 09:26
@@ -69,4 +69,16 @@ func XCTAssertThrowsFileSystemErrorAsync<R>(
}
}
}

func XCTAssertNoThrowAsync<T>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't squat on XCTest's XCT* name space, you can make it NIOAssertNoThrowAsync or smth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants