mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-23 04:28:48 -05:00
+31
@@ -559,6 +559,37 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re
|
||||
return nil
|
||||
}
|
||||
|
||||
isParent, err := s.referenceIsChildOf(ctx, s.gatewaySelector, srcRef, dstRef)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case errtypes.IsNotFound:
|
||||
isParent = false
|
||||
case errtypes.IsNotSupported:
|
||||
log.Error().Err(err).Msg("can not detect recursive copy operation. missing machine auth configuration?")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return nil
|
||||
default:
|
||||
log.Error().Err(err).Msg("error while trying to detect recursive copy operation")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if isParent {
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
b, err := errors.Marshal(http.StatusBadRequest, "can not copy a folder into its parent", "")
|
||||
errors.HandleWebdavError(log, w, b, err)
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
if srcRef.Path == dstRef.Path && srcRef.ResourceId == dstRef.ResourceId {
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
b, err := errors.Marshal(http.StatusBadRequest, "source and destination are the same", "")
|
||||
errors.HandleWebdavError(log, w, b, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
oh := r.Header.Get(net.HeaderOverwrite)
|
||||
overwrite, err := net.ParseOverwrite(oh)
|
||||
if err != nil {
|
||||
|
||||
+23
@@ -162,6 +162,29 @@ func (s *svc) handleMove(ctx context.Context, w http.ResponseWriter, r *http.Req
|
||||
return
|
||||
}
|
||||
|
||||
isParent, err := s.referenceIsChildOf(ctx, s.gatewaySelector, src, dst)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case errtypes.IsNotFound:
|
||||
isParent = false
|
||||
case errtypes.IsNotSupported:
|
||||
log.Error().Err(err).Msg("can not detect recursive move operation. missing machine auth configuration?")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
default:
|
||||
log.Error().Err(err).Msg("error while trying to detect recursive move operation")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
if isParent {
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
b, err := errors.Marshal(http.StatusBadRequest, "can not move a folder into its parent", "")
|
||||
errors.HandleWebdavError(&log, w, b, err)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
oh := r.Header.Get(net.HeaderOverwrite)
|
||||
log.Debug().Str("overwrite", oh).Msg("move")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user