diff --git a/changelog/unreleased/do-not-replace-file-when-copying.md b/changelog/unreleased/do-not-replace-file-when-copying.md new file mode 100644 index 0000000000..9f8567c6ca --- /dev/null +++ b/changelog/unreleased/do-not-replace-file-when-copying.md @@ -0,0 +1,11 @@ +Bugfix: Do not lose old revisions when overwriting a file during copy + +We no longer delete-and-upload targets of copy operations but rather +add a new version with the source content. + +This makes "overwrite when copying" behave the same as "overwrite when uploading". + +Overwriting when moving a file still deletes the old file (moves it into the +trash) and replaces the whole file including the revisions of the source file. + +https://github.com/cs3org/reva/pull/3896 diff --git a/changelog/unreleased/fix-preflight-requests.md b/changelog/unreleased/fix-preflight-requests.md index 42f7d01020..2197db5ec1 100644 --- a/changelog/unreleased/fix-preflight-requests.md +++ b/changelog/unreleased/fix-preflight-requests.md @@ -2,4 +2,4 @@ Bugfix: fix preflight requests The datagateway now correctly overwrites the preconfigured CORS related headers with the headers returned by a dataprovider. -https://github.com/cs3org/reva/pull/ +https://github.com/cs3org/reva/pull/3906 diff --git a/internal/http/services/owncloud/ocdav/copy.go b/internal/http/services/owncloud/ocdav/copy.go index 8fd20484e4..4dc25f6bb8 100644 --- a/internal/http/services/owncloud/ocdav/copy.go +++ b/internal/http/services/owncloud/ocdav/copy.go @@ -616,18 +616,22 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re return nil } - // delete existing tree - delReq := &provider.DeleteRequest{Ref: dstRef} - delRes, err := s.gwClient.Delete(ctx, delReq) - if err != nil { - log.Error().Err(err).Msg("error sending grpc delete request") - w.WriteHeader(http.StatusInternalServerError) - return nil - } + // delete existing tree when overwriting a directory or replacing a file with a directory + if dstStatRes.Info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER || + (dstStatRes.Info.Type == provider.ResourceType_RESOURCE_TYPE_FILE && + srcStatRes.Info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER) { + delReq := &provider.DeleteRequest{Ref: dstRef} + delRes, err := s.gwClient.Delete(ctx, delReq) + if err != nil { + log.Error().Err(err).Msg("error sending grpc delete request") + w.WriteHeader(http.StatusInternalServerError) + return nil + } - if delRes.Status.Code != rpc.Code_CODE_OK && delRes.Status.Code != rpc.Code_CODE_NOT_FOUND { - errors.HandleErrorStatus(log, w, delRes.Status) - return nil + if delRes.Status.Code != rpc.Code_CODE_OK && delRes.Status.Code != rpc.Code_CODE_NOT_FOUND { + errors.HandleErrorStatus(log, w, delRes.Status) + return nil + } } } else if p := path.Dir(dstRef.Path); p != "" { // check if an intermediate path / the parent exists