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

add CloserListerAt #577

Merged
merged 1 commit into from Apr 10, 2024
Merged

add CloserListerAt #577

merged 1 commit into from Apr 10, 2024

Conversation

drakkan
Copy link
Collaborator

@drakkan drakkan commented Feb 9, 2024

The ListerAt is stored in the Request state and reused across requests. Some implementations don't store the entire []os.FileInfo buffer in the ListerAt implementation but instead return an open file and get/return []os.FileInfo on request. For these implementation a Close method is required.

The use case is if you want to list a large directory on memory constrained systems.

request-interfaces.go Outdated Show resolved Hide resolved
request.go Outdated Show resolved Hide resolved
request.go Outdated
@@ -229,6 +241,8 @@ func (r *Request) close() error {
}
}()

r.state.closeListerAt()
Copy link
Collaborator

Choose a reason for hiding this comment

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

err := r.state.closeListerAt()

Perhaps? This obviates the need for line 248 as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe we can just check for io.Closer like for readers/writers instead of extending the interface

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think that’s a simpler mor direct change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think that’s a simpler mor direct change.

Done

@drakkan drakkan force-pushed the lister-close branch 3 times, most recently from 311ff0d to 8fe951f Compare February 12, 2024 09:33
The ListerAt is stored in the Request state and reused across requests.
Some implementations don't store the entire []os.FileInfo buffer in the
ListerAt implementation but instead return an open file and get/return
[]os.FileInfo on request. For these implementation calling Close is
required
@drakkan drakkan merged commit 6370888 into pkg:master Apr 10, 2024
4 checks passed
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.

None yet

2 participants