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

GH-643: provide interfaces for caching file attributes on paths #645

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

tomaswolf
Copy link
Member

Remote file systems may have a need to cache file attributes on Path instances. A typical use case is iterating over all files in a directory: the directory listing returns paths, but the underlying remote listing operation may also return file attributes for each entry. This is the case in Sftp, but may also occur for other file systems, for instance a file system wrapping Amazon S3.

It would be unfortunate and inefficient if iterating through the paths returned and doing something with the attributes would have to re-fetch the attributes again if they were already available.

By implementing WithFileAttributes on its Paths, a file system can associate file attributes with a path instance, and client code can access them. If a file system also makes its paths implement the second interface WithFileAttributeCache, then the SftpSubsystem uses it internally to avoid making repeated remote calls to get file attributes.

Remote file systems may have a need to cache file attributes on Path
instances. A typical use case is iterating over all files in a
directory: the directory listing returns paths, but the underlying
remote listing operation may also return file attributes for each entry.
This is the case in Sftp, but may also occur for other file systems, for
instance a file system wrapping Amazon S3.

It would be unfortunate and inefficient if iterating through the paths
returned and doing something with the attributes would have to re-fetch
the attributes again if they were already available.

By implementing WithFileAttributes of its Paths, a file system can
associate file attributes with a path instance, and client code can
access them. If a file system also makes its paths implement the second
interface WithFileAttributeCache, then the SftpSubsystem uses it
internally to avoid making repeated remote calls to get file attributes.
@tomaswolf tomaswolf merged commit 03cee94 into apache:master Dec 18, 2024
7 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.

1 participant