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

feat: map blobstore implements filesystemer #14

Merged
merged 6 commits into from
Oct 28, 2024

Conversation

alanshaw
Copy link
Member

This PR enables the map blobstore to present itself as a http.FileSystem. This is useful for testing with an ephemeral storage node.

@alanshaw alanshaw requested a review from hannahhoward October 26, 2024 23:02
Copy link
Member

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

LGTM with some suggestions to look into (non-blocking)

@@ -36,19 +36,7 @@ func NewBlobGetHandler(blobs blobstore.Blobstore) func(http.ResponseWriter, *htt
if fsblobs, ok := blobs.(blobstore.FileSystemer); ok {
serveHTTP := http.FileServer(fsblobs.FileSystem()).ServeHTTP
return func(w http.ResponseWriter, r *http.Request) {
_, bytes, err := multibase.Decode(r.PathValue("blob"))
Copy link
Member

Choose a reason for hiding this comment

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

this might be simpler with ServeFile instead of FileServer.

also go errata: if you just want to use system utils, you may find ServeFileFS and FileServerFS easer cause you can just use some system utils (if this is actually helpful)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes - looks more appropriate. I didn't realize it existed! If I have a moment I'll look into replacing it.

@@ -28,7 +28,12 @@ func (srv *Server) Serve(mux *http.ServeMux) {

func NewHandler(server server.ServerView) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
res, _ := server.Request(ucanhttp.NewHTTPRequest(r.Body, r.Header))
res, err := server.Request(ucanhttp.NewHTTPRequest(r.Body, r.Header))
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -194,3 +191,21 @@ func NewFsBlobstore(rootdir string, tmpdir string) (*FsBlobstore, error) {
}
return &FsBlobstore{rootdir, tmpdir}, nil
}

type fsDir struct {
Copy link
Member

Choose a reason for hiding this comment

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

again you may want to look at fs.FS

@alanshaw alanshaw merged commit 3644eb9 into main Oct 28, 2024
4 checks passed
@alanshaw alanshaw deleted the feat/map-blobstore-implements-filesystemer branch October 28, 2024 16:42
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