Skip to content

Commit

Permalink
Merge pull request #3896 from aduffeck/dont-lose-revisions-when-repla…
Browse files Browse the repository at this point in the history
…cing

Dont lose revisions when replacing
  • Loading branch information
aduffeck authored May 23, 2023
2 parents 0d66bdd + 9a8900c commit fd38e8a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
11 changes: 11 additions & 0 deletions changelog/unreleased/do-not-replace-file-when-copying.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion changelog/unreleased/fix-preflight-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 15 additions & 11 deletions internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd38e8a

Please sign in to comment.