Skip to content

Commit

Permalink
feat(ocm): send locktoken with PUT request
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Dec 12, 2024
1 parent 5a42fea commit cf6201f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
uReq := &provider.InitiateFileUploadRequest{
Ref: cs3Ref,
Opaque: req.Opaque,
LockId: req.LockId,
}

gatewayClient, err := s.gatewaySelector.Next()
Expand Down
5 changes: 3 additions & 2 deletions pkg/ocm/storage/received/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func (d *driver) Upload(ctx context.Context, req storage.UploadRequest, _ storag
}
})

return &provider.ResourceInfo{}, client.WriteStream(rel, req.Body, 0)
locktoken, _ := ctxpkg.ContextGetLockID(ctx)
return &provider.ResourceInfo{}, client.WriteStream(rel, req.Body, 0, locktoken)
}

// UseIn tells the tus upload middleware which extensions it supports.
Expand Down Expand Up @@ -356,7 +357,7 @@ func (u *upload) FinishUpload(ctx context.Context) error {
return err
}
defer f.Close()
return client.WriteStream(rel, f, 0)
return client.WriteStream(rel, f, 0, "")
}

func (u *upload) Terminate(ctx context.Context) error {
Expand Down
5 changes: 5 additions & 0 deletions pkg/rhttp/datatx/manager/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -109,6 +110,10 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {

ref := &provider.Reference{Path: fn}

if lockID := r.Header.Get("X-Lock-Id"); lockID != "" {
ctx = ctxpkg.ContextSetLockID(ctx, lockID)
}

info, err := fs.Upload(ctx, storage.UploadRequest{
Ref: ref,
Body: r.Body,
Expand Down

0 comments on commit cf6201f

Please sign in to comment.