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

Use fs.FS for filesystem access #8

Open
joonas-fi opened this issue Sep 3, 2021 · 2 comments
Open

Use fs.FS for filesystem access #8

joonas-fi opened this issue Sep 3, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@joonas-fi
Copy link
Contributor

Go's new FS interface is pretty cool, I've used in quite a few projects to serve files embedded into the binary, to do overlayFS-like stuff (merge multiple directories as one) etc. fs.FS enables all of this craziness.

My proposal: instead of giving direct filesystem path like /my/path to a module, the module would take in fs.FS and you could give in os.DirFS("/my/path").

I am willing to send a PR if you are interested. I have not read through the server code to check if there are any requirements that don't have direct analogies in fs interfaces. uid/gid things in Stat() calls would be one thing not present in fs.FileInfo. Those cases would need to be type-switched on (check if stat result is a structure that actually carries uid/gid)

@stapelberg stapelberg added the enhancement New feature or request label Sep 3, 2021
@stapelberg
Copy link
Contributor

Yeah, I think we should do this. Probably better to wait until next week, because I’m planning to do some work around extendend attributes and such. I assume that afterwards, I’ll have a much better idea of how much is covered by fs.FS, or what extra things we need :)

@stapelberg
Copy link
Contributor

Okay, I think the file handling bits are done (or done enough) now:

func (s *Server) sendFileList(c *rsyncConn, root string, opts rsyncOpts) (*fileList, error) {

Aside from file paths and stat(2) results, we also need symlink target resolution.

Use-case wise, aside from serving static assets and serving the file system, it would be interesting to sketch whether to-be-served data can be generated on the fly, too, with the fs.FS interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants