Skip to content

Use most up-to-date FileHandle APIs#74

Merged
dfed merged 5 commits into
mainfrom
dfed--no-underscore
Nov 10, 2022
Merged

Use most up-to-date FileHandle APIs#74
dfed merged 5 commits into
mainfrom
dfed--no-underscore

Conversation

@dfed

@dfed dfed commented Nov 8, 2022

Copy link
Copy Markdown
Owner

When iOS 13 / tvOS 13 / watchOS 6 / macOS 10.15 were released, Apple deprecated the readData(ofLength:) and the write(_:) methods, but did not replace them with any new documented methods. The only available, non-deprecated replacements for these methods were __readDataUp(toLength:) and __write(_:, error:), but neither were documented.

Then in iOS 13.4 / tvOS 13.4 / watchOS 6.2 / macOS 10.15.4 Apple fixed their mistake, introducing the APIs read(upToCount:) and write(contentsOf:). This PR adopts these newer methods.

It is expected that this PR will lower our code coverage, since we do not have CI running on iOS 13.0<=13.4 / tvOS 13.0<=13.4 / watchOS 6<=6.2 / macOS 10.15.0<=10.15.4

@codecov

codecov Bot commented Nov 8, 2022

Copy link
Copy Markdown

Codecov Report

Merging #74 (7e6962e) into main (26a1c97) will increase coverage by 2.47%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   96.44%   98.92%   +2.47%     
==========================================
  Files          14       13       -1     
  Lines         591      556      -35     
==========================================
- Hits          570      550      -20     
+ Misses         21        6      -15     
Impacted Files Coverage Δ
Sources/CacheAdvance/FileHandleExtensions.swift

Comment thread codecov.yml
patch: off

ignore:
- "Sources/CacheAdvance/FileHandleExtensions.swift"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ignoring this file because due to limitations of Github Actions we can't test most of the branches in this file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we add a comment to this effect?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

done!

Comment thread codecov.yml
patch: off

ignore:
- "Sources/CacheAdvance/FileHandleExtensions.swift"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we add a comment to this effect?

if let data = try read(upToCount: length) {
return data
} else {
return Data()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's interesting that the method both throws and returns a nullable result. I wonder how you could end up with nil? In any case, do you think we should throw our own error if the data is nil?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Oh we end up with nil when the data is empty. I tried throwing here instead of returning Data() and I broke a ton of tests. Returning Data() here preserves existing behavior.

@dfed dfed merged commit 61f099f into main Nov 10, 2022
@dfed dfed deleted the dfed--no-underscore branch November 10, 2022 04:43
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