Skip to content

Commit

Permalink
Added support for HTTP TPC
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamic-entropy committed Aug 19, 2021
1 parent 7f7fab2 commit 028a0cd
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 1 deletion.
10 changes: 10 additions & 0 deletions changelog/unreleased/http-tpc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Enhancement: Add support for HTTP TPC

We have added support for Http Third Party Copy.
This allows remote data transfer between storages managed by:

1. Two different reva servers
2. A reva server and a grid site server

https://github.com/cs3org/reva/issues/1787
https://github.com/cs3org/reva/pull/2007
19 changes: 18 additions & 1 deletion internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,35 @@ func (s *svc) handlePathCopy(w http.ResponseWriter, r *http.Request, ns string)
ctx, span := rtrace.Provider.Tracer("reva").Start(r.Context(), "copy")
defer span.End()

// If is a third party copy
if r.Header.Get("ThirdPartyCopy") == "T" {

// Push Mode
if r.Header.Get("Source") == "" {
s.handleTPCPush(ctx, w, r, ns)
return
}

// Pull Mode
s.handleTPCPull(ctx, w, r, ns)
return
}

// is a local copy
src := path.Join(ns, r.URL.Path)
dst, err := extractDestination(r)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}

for _, r := range nameRules {
if !r.Test(dst) {
w.WriteHeader(http.StatusBadRequest)
return
}
}

dst = path.Join(ns, dst)

sublog := appctx.GetLogger(ctx).With().Str("src", src).Str("dst", dst).Logger()
Expand Down Expand Up @@ -96,8 +113,8 @@ func (s *svc) handlePathCopy(w http.ResponseWriter, r *http.Request, ns string)
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(cp.successCode)
}

}
func (s *svc) executePathCopy(ctx context.Context, client gateway.GatewayAPIClient, w http.ResponseWriter, r *http.Request, cp *copy) error {
log := appctx.GetLogger(ctx)
log.Debug().Str("src", cp.sourceInfo.Path).Str("dst", cp.destination.Path).Msg("descending")
Expand Down
Loading

0 comments on commit 028a0cd

Please sign in to comment.