refactor(tvix/nar-bridge): drop reader package

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>
This commit is contained in:
Florian Klink 2023-10-03 12:57:03 +03:00 committed by clbot
parent 6e9a5dcd59
commit b1ff1267be
6 changed files with 41 additions and 56 deletions

View file

@ -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)