diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-25 14:26:17 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-25 14:26:17 +0200 |
commit | af3f5e2b9139674b49c5caf0bc06e93cbc426727 (patch) | |
tree | 06dbaadba6bbee95afd3212438e2434846312dcc /plumbing/transport/server/server.go | |
parent | 8e83055176bbbbbde206884f10dc238fd378b9b4 (diff) | |
download | go-git-af3f5e2b9139674b49c5caf0bc06e93cbc426727.tar.gz |
transport: context package support
Diffstat (limited to 'plumbing/transport/server/server.go')
-rw-r--r-- | plumbing/transport/server/server.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go index 7c78afe..be36de5 100644 --- a/plumbing/transport/server/server.go +++ b/plumbing/transport/server/server.go @@ -3,6 +3,7 @@ package server import ( + "context" "errors" "fmt" "io" @@ -14,6 +15,7 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/revlist" "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/plumbing/transport" + "gopkg.in/src-d/go-git.v4/utils/ioutil" ) var DefaultServer = NewServer(DefaultLoader) @@ -129,7 +131,7 @@ func (s *upSession) AdvertisedReferences() (*packp.AdvRefs, error) { return ar, nil } -func (s *upSession) UploadPack(req *packp.UploadPackRequest) (*packp.UploadPackResponse, error) { +func (s *upSession) UploadPack(ctx context.Context, req *packp.UploadPackRequest) (*packp.UploadPackResponse, error) { if req.IsEmpty() { return nil, transport.ErrEmptyUploadPackRequest } @@ -167,7 +169,9 @@ func (s *upSession) UploadPack(req *packp.UploadPackRequest) (*packp.UploadPackR pw.CloseWithError(err) }() - return packp.NewUploadPackResponseWithPackfile(req, pr), nil + return packp.NewUploadPackResponseWithPackfile(req, + ioutil.NewContextReadCloser(ctx, pr), + ), nil } func (s *upSession) objectsToUpload(req *packp.UploadPackRequest) ([]plumbing.Hash, error) { @@ -222,7 +226,7 @@ var ( ErrUpdateReference = errors.New("failed to update ref") ) -func (s *rpSession) ReceivePack(req *packp.ReferenceUpdateRequest) (*packp.ReportStatus, error) { +func (s *rpSession) ReceivePack(ctx context.Context, req *packp.ReferenceUpdateRequest) (*packp.ReportStatus, error) { if s.caps == nil { s.caps = capability.NewList() if err := s.setSupportedCapabilities(s.caps); err != nil { @@ -238,7 +242,8 @@ func (s *rpSession) ReceivePack(req *packp.ReferenceUpdateRequest) (*packp.Repor //TODO: Implement 'atomic' update of references. - if err := s.writePackfile(req.Packfile); err != nil { + r := ioutil.NewContextReadCloser(ctx, req.Packfile) + if err := s.writePackfile(r); err != nil { s.unpackErr = err s.firstErr = err return s.reportStatus(), err |