diff --git a/cmd/objgitd/daemon.go b/cmd/objgitd/daemon.go index cef5e9c..4852240 100644 --- a/cmd/objgitd/daemon.go +++ b/cmd/objgitd/daemon.go @@ -33,19 +33,6 @@ type daemon struct { allowPush bool } -// plainStorer hides the underlying storer's PackfileWriter implementation. -// -// transport.ReceivePack stores an incoming pack via packfile.UpdateObjectStorage, -// which has two paths: a storer.PackfileWriter fast-path that copies the client -// stream to EOF, and a parser fallback that reads exactly one self-delimiting -// pack. A git:// client keeps the socket open after its pack, waiting for -// report-status, so it never sends EOF and the fast-path copy deadlocks. By not -// advertising PackfileWriter we take the parser path, which stops at the pack -// trailer. Objects land as loose objects rather than a packfile. -type plainStorer struct { - storage.Storer -} - // Serve accepts connections on l until ctx is cancelled or Accept fails. func (d *daemon) Serve(ctx context.Context, l net.Listener) error { go func() { @@ -114,6 +101,14 @@ func (d *daemon) handle(ctx context.Context, conn net.Conn) error { GitProtocol: gitProtocol, }) + case transport.UploadArchiveService: + st, err := d.loader.Load(&url.URL{Path: req.Pathname}) + if err != nil { + _, _ = pktline.WriteError(conn, fmt.Errorf("repository %q not found", req.Pathname)) + return fmt.Errorf("loading %q: %w", req.Pathname, err) + } + return transport.UploadArchive(ctx, st, r, conn, &transport.UploadArchiveRequest{}) + case transport.ReceivePackService: if !d.allowPush { _, _ = pktline.WriteError(conn, fmt.Errorf("push is disabled on this server")) @@ -124,7 +119,7 @@ func (d *daemon) handle(ctx context.Context, conn net.Conn) error { _, _ = pktline.WriteError(conn, fmt.Errorf("cannot open repository %q", req.Pathname)) return fmt.Errorf("opening %q for push: %w", req.Pathname, err) } - return transport.ReceivePack(ctx, plainStorer{st}, r, conn, &transport.ReceivePackRequest{ + return transport.ReceivePack(ctx, st, r, conn, &transport.ReceivePackRequest{ GitProtocol: gitProtocol, })