Skip to content

Commit

Permalink
Add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Nov 20, 2024
1 parent 4f31fd9 commit 2ec4e80
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
Expand Down Expand Up @@ -141,8 +142,11 @@ func (s *svc) Handler() http.Handler {
func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

log := appctx.GetLogger(ctx)

client, err := pool.GetGatewayServiceClient(s.conf.GatewaySvc)
if err != nil {
log.Error().Err(err).Msg("error getting grpc gateway client")
writeError(w, r, appErrorServerError, "error getting grpc gateway client", err)
return
}
Expand Down Expand Up @@ -189,6 +193,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
}
parentContainer, err := client.Stat(ctx, statParentContainerReq)
if err != nil {
log.Error().Err(err).Msg("error statting the parent container")
writeError(w, r, appErrorServerError, "error sending a grpc stat request", err)
return
}
Expand All @@ -213,6 +218,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
}
statFileRes, err := client.Stat(ctx, statFileReq)
if err != nil {
log.Error().Err(err).Msg("error statting the file")
writeError(w, r, appErrorServerError, "failed to stat the file", err)
return
}
Expand All @@ -222,6 +228,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
writeError(w, r, appErrorAlreadyExists, "the file already exists", nil)
return
}
log.Error().Interface("statFileRes", statFileRes).Msg("statting the file returned unexpected status code")
writeError(w, r, appErrorServerError, "statting the file returned unexpected status code", err)
return
}
Expand All @@ -232,6 +239,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {

touchRes, err := client.TouchFile(ctx, touchFileReq)
if err != nil {
log.Error().Err(err).Msg("error touching the file")
writeError(w, r, appErrorServerError, "error sending a grpc touchfile request", err)
return
}
Expand All @@ -244,11 +252,13 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
// Stat the newly created file
statRes, err := client.Stat(ctx, statFileReq)
if err != nil {
log.Error().Err(err).Msg("error statting the created file")
writeError(w, r, appErrorServerError, "statting the created file failed", err)
return
}

if statRes.Status.Code != rpc.Code_CODE_OK {
log.Error().Interface("statRes", statRes).Msg("statting the created file returned unexpected status code")
writeError(w, r, appErrorServerError, "statting the created file failed", nil)
return
}
Expand All @@ -265,12 +275,14 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) {
},
)
if err != nil {
log.Error().Err(err).Msg("error marshalling JSON response")
writeError(w, r, appErrorServerError, "error marshalling JSON response", err)
return
}

w.Header().Set("Content-Type", "application/json")
if _, err = w.Write(js); err != nil {
log.Error().Err(err).Msg("error writing JSON response")
writeError(w, r, appErrorServerError, "error writing JSON response", err)
return
}
Expand Down

0 comments on commit 2ec4e80

Please sign in to comment.