diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-03T09·57+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-10-05T06·11+0000 |
commit | b1ff1267be5f1dfa4f764648da68bbaec8366ecd (patch) | |
tree | 533d5a6af668d83db37148e18e4c311ddf49a933 /tvix/nar-bridge/pkg/server | |
parent | 6e9a5dcd5937496e4fb5ef6ebcc2b9875be4c68b (diff) |
refactor(tvix/nar-bridge): drop reader package r/6693
Make the import function usable on any reader. Change-Id: I84d2004cb73cdd7a11fe8efb0f2efb6335d5e6b0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9527 Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nar-bridge/pkg/server')
-rw-r--r-- | tvix/nar-bridge/pkg/server/blob_upload.go | 2 | ||||
-rw-r--r-- | tvix/nar-bridge/pkg/server/nar_put.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tvix/nar-bridge/pkg/server/blob_upload.go b/tvix/nar-bridge/pkg/server/blob_upload.go index 87d3918efa87..5531335367df 100644 --- a/tvix/nar-bridge/pkg/server/blob_upload.go +++ b/tvix/nar-bridge/pkg/server/blob_upload.go @@ -16,7 +16,7 @@ import ( const chunkSize = 1024 * 1024 // this produces a callback function that can be used as blobCb for the -// reader.Import function call +// importer.Import function call. func genBlobServiceWriteCb(ctx context.Context, blobServiceClient castorev1pb.BlobServiceClient) func(io.Reader) error { return func(blobReader io.Reader) error { // Ensure the blobReader is buffered to at least the chunk size. diff --git a/tvix/nar-bridge/pkg/server/nar_put.go b/tvix/nar-bridge/pkg/server/nar_put.go index 68529d6c3a17..0cb0190b7c6f 100644 --- a/tvix/nar-bridge/pkg/server/nar_put.go +++ b/tvix/nar-bridge/pkg/server/nar_put.go @@ -7,7 +7,7 @@ import ( "net/http" castorev1pb "code.tvl.fyi/tvix/castore/protos" - "code.tvl.fyi/tvix/nar-bridge/pkg/reader" + "code.tvl.fyi/tvix/nar-bridge/pkg/importer" "github.com/go-chi/chi/v5" nixhash "github.com/nix-community/go-nix/pkg/hash" "github.com/nix-community/go-nix/pkg/nixbase32" @@ -39,10 +39,10 @@ func registerNarPut(s *Server) { directoriesUploader := NewDirectoriesUploader(ctx, s.directoryServiceClient) defer directoriesUploader.Done() //nolint:errcheck - // buffer the body by 10MiB - rd := reader.New(bufio.NewReaderSize(r.Body, 10*1024*1024)) - pathInfo, err := rd.Import( + pathInfo, err := importer.Import( ctx, + // buffer the body by 10MiB + bufio.NewReaderSize(r.Body, 10*1024*1024), genBlobServiceWriteCb(ctx, s.blobServiceClient), func(directory *castorev1pb.Directory) error { return directoriesUploader.Put(directory) |