+8
-1
@@ -697,7 +697,14 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re
|
||||
|
||||
// we must not allow to override mountpoints - so we check if we have access to the parent. If not this is a mountpoint
|
||||
if destInShareJail {
|
||||
dir, file := filepath.Split(dstRef.GetPath())
|
||||
res, err := client.GetPath(ctx, &provider.GetPathRequest{ResourceId: dstStatRes.GetInfo().GetId()})
|
||||
if err != nil || res.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
log.Error().Err(err).Msg("error sending grpc get path request")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return nil
|
||||
}
|
||||
|
||||
dir, file := filepath.Split(filepath.Clean(res.GetPath()))
|
||||
if dir == "/" || dir == "" || file == "" {
|
||||
log.Error().Msg("must not overwrite mount points")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
||||
Generated
Vendored
+10
-5
@@ -295,12 +295,17 @@ func (h *Handler) isPublicShare(r *http.Request, oid string) (*link.PublicShare,
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Err(err)
|
||||
return nil, false
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Err(err).Send()
|
||||
case psRes.Status.Code == rpc.Code_CODE_OK:
|
||||
return psRes.GetShare(), psRes.GetShare() != nil
|
||||
case psRes.Status.Code == rpc.Code_CODE_INTERNAL:
|
||||
log.Error().Str("message", psRes.GetStatus().GetMessage()).Str("code", psRes.GetStatus().GetCode().String()).Msg("isPublicShare received internal error")
|
||||
default:
|
||||
log.Debug().Str("message", psRes.GetStatus().GetMessage()).Str("code", psRes.GetStatus().GetCode().String()).Msg("isPublicShare received unexpected status")
|
||||
}
|
||||
|
||||
return psRes.GetShare(), psRes.GetShare() != nil
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, share *link.PublicShare) {
|
||||
|
||||
Generated
Vendored
+3
-3
@@ -634,7 +634,7 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if share == nil {
|
||||
if h.listOCMShares && share == nil {
|
||||
// check if we have a federated share
|
||||
req := &ocm.GetOCMShareRequest{
|
||||
Ref: &ocm.ShareReference{
|
||||
@@ -662,7 +662,7 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if share == nil {
|
||||
if h.listOCMShares && share == nil {
|
||||
// check if we have an incoming federated share
|
||||
req := &ocm.GetReceivedOCMShareRequest{
|
||||
Ref: &ocm.ShareReference{
|
||||
@@ -912,7 +912,7 @@ func (h *Handler) RemoveShare(w http.ResponseWriter, r *http.Request) {
|
||||
h.removeUserShare(w, r, share)
|
||||
return
|
||||
}
|
||||
if h.isFederatedShare(r, shareID) {
|
||||
if h.listOCMShares && h.isFederatedShare(r, shareID) {
|
||||
h.removeFederatedShare(w, r, shareID)
|
||||
return
|
||||
}
|
||||
|
||||
Generated
Vendored
+30
-15
@@ -132,10 +132,10 @@ func (h *Handler) createUserShare(w http.ResponseWriter, r *http.Request, statIn
|
||||
}
|
||||
|
||||
func (h *Handler) isUserShare(r *http.Request, oid string) (*collaboration.Share, bool) {
|
||||
logger := appctx.GetLogger(r.Context())
|
||||
log := appctx.GetLogger(r.Context())
|
||||
client, err := pool.GetGatewayServiceClient(h.gatewayAddr)
|
||||
if err != nil {
|
||||
logger.Err(err)
|
||||
log.Err(err).Send()
|
||||
}
|
||||
|
||||
getShareRes, err := client.GetShare(r.Context(), &collaboration.GetShareRequest{
|
||||
@@ -147,12 +147,17 @@ func (h *Handler) isUserShare(r *http.Request, oid string) (*collaboration.Share
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Err(err)
|
||||
return nil, false
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Err(err).Send()
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_OK:
|
||||
return getShareRes.GetShare(), true
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL:
|
||||
log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isUserShare received internal error")
|
||||
default:
|
||||
log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isUserShare received unexpected status")
|
||||
}
|
||||
|
||||
return getShareRes.GetShare(), getShareRes.GetShare() != nil
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (h *Handler) isFederatedShare(r *http.Request, shareID string) bool {
|
||||
@@ -172,12 +177,17 @@ func (h *Handler) isFederatedShare(r *http.Request, shareID string) bool {
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Err(err).Send()
|
||||
return false
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_OK:
|
||||
return true
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL:
|
||||
log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedShare received internal error")
|
||||
default:
|
||||
log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedShare received unexpected status")
|
||||
}
|
||||
|
||||
return getShareRes.GetShare() != nil
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *Handler) removeFederatedShare(w http.ResponseWriter, r *http.Request, shareID string) {
|
||||
@@ -247,12 +257,17 @@ func (h *Handler) isFederatedReceivedShare(r *http.Request, shareID string) bool
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Err(err).Send()
|
||||
return false
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_OK:
|
||||
return true
|
||||
case getShareRes.Status.Code == rpc.Code_CODE_INTERNAL:
|
||||
log.Error().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedReceivedShare received internal error")
|
||||
default:
|
||||
log.Debug().Str("message", getShareRes.GetStatus().GetMessage()).Str("code", getShareRes.GetStatus().GetCode().String()).Msg("isFederatedReceivedShare received unexpected status")
|
||||
}
|
||||
|
||||
return getShareRes.GetShare() != nil
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *Handler) removeUserShare(w http.ResponseWriter, r *http.Request, share *collaboration.Share) {
|
||||
|
||||
Reference in New Issue
Block a user