Skip to content

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

Merged
tomaswolf merged 1 commit into
apache:masterfrom
tomaswolf:gh-643
Dec 18, 2024
Merged

GH-643: provide interfaces for caching file attributes on paths#645
tomaswolf merged 1 commit into
apache:masterfrom
tomaswolf:gh-643

Conversation

@tomaswolf
Copy link
Copy Markdown
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
@tomaswolf tomaswolf deleted the gh-643 branch April 25, 2025 15:34
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