Skip to content

Commit

Permalink
unwrap and spaces cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Aug 12, 2021
1 parent c13d9b1 commit f0ecf47
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
13 changes: 4 additions & 9 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,9 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
log := appctx.GetLogger(ctx)
newRef, err := s.unwrap(ctx, req.Ref)
if err != nil {
switch err.(type) {
case errtypes.IsNotFound:
newRef = req.Ref
default:
return &provider.InitiateFileUploadResponse{
Status: status.NewInternal(ctx, err, "error unwrapping path"),
}, nil
}
return &provider.InitiateFileUploadResponse{
Status: status.NewInternal(ctx, err, "error unwrapping path"),
}, nil
}
if newRef.GetPath() == "/" {
return &provider.InitiateFileUploadResponse{
Expand Down Expand Up @@ -346,7 +341,7 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
st = status.NewNotFound(ctx, "path not found when initiating upload")
case errtypes.IsBadRequest, errtypes.IsChecksumMismatch:
st = status.NewInvalidArg(ctx, err.Error())
// TODO TUS uses a custom ChecksumMismatch 460 http status which is in an unnasigned range in
// TODO TUS uses a custom ChecksumMismatch 460 http status which is in an unassigned range in
// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
// maybe 409 conflict is good enough
// someone is proposing `419 Checksum Error`, see https://stackoverflow.com/a/35665694
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type intermediateDirRefFunc func() (*provider.Reference, *rpc.Status, error)

func (s *svc) handlePathCopy(w http.ResponseWriter, r *http.Request, ns string) {
ctx := r.Context()
ctx, span := trace.StartSpan(ctx, "head")
ctx, span := trace.StartSpan(ctx, "copy")
defer span.End()

src := path.Join(ns, r.URL.Path)
Expand Down Expand Up @@ -260,7 +260,7 @@ func (s *svc) executePathCopy(ctx context.Context, client gateway.GatewayAPIClie

func (s *svc) handleSpacesCopy(w http.ResponseWriter, r *http.Request, spaceID string) {
ctx := r.Context()
ctx, span := trace.StartSpan(ctx, "head")
ctx, span := trace.StartSpan(ctx, "spaces_copy")
defer span.End()

dst, err := extractDestination(r)
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *svc) handlePathPropfind(w http.ResponseWriter, r *http.Request, ns stri

func (s *svc) handleSpacesPropfind(w http.ResponseWriter, r *http.Request, spaceID string) {
ctx := r.Context()
ctx, span := trace.StartSpan(ctx, "propfind")
ctx, span := trace.StartSpan(ctx, "spaces_propfind")
defer span.End()

sublog := appctx.GetLogger(ctx).With().Str("path", r.URL.Path).Str("spaceid", spaceID).Logger()
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *svc) adjustResourcePathInURL(w http.ResponseWriter, r *http.Request) bo
// ns is the namespace that is prefixed to the path in the cs3 namespace
func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns string, onContainer bool) {
ctx := r.Context()
ctx, span := trace.StartSpan(ctx, "propfind")
ctx, span := trace.StartSpan(ctx, "token_propfind")
defer span.End()

tokenStatInfo := ctx.Value(tokenStatInfoKey{}).(*provider.ResourceInfo)
Expand Down
2 changes: 2 additions & 0 deletions internal/http/services/owncloud/ocdav/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ func (s *svc) handlePut(ctx context.Context, w http.ResponseWriter, r *http.Requ

func (s *svc) handleSpacesPut(w http.ResponseWriter, r *http.Request, spaceID string) {
ctx := r.Context()
ctx, span := trace.StartSpan(ctx, "spaces_put")
defer span.End()

sublog := appctx.GetLogger(ctx).With().Str("spaceid", spaceID).Str("path", r.URL.Path).Logger()

Expand Down

0 comments on commit f0ecf47

Please sign in to comment.