Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement missing ocdav versions API endpoints #2855

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/ocdav-versions-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add download endpoint to ocdav versions API

Added missing endpoints to the ocdav versions API. This enables downloads of previous file versions.

https://github.com/owncloud/ocis/issues/3741
https://github.com/cs3org/reva/pull/2855
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (s *svc) handleGet(ctx context.Context, w http.ResponseWriter, r *http.Requ

w.Header().Set(net.HeaderContentType, info.MimeType)
w.Header().Set(net.HeaderContentDisposistion, "attachment; filename*=UTF-8''"+
path.Base(r.URL.Path)+"; filename=\""+path.Base(r.URL.Path)+"\"")
path.Base(info.Path)+"; filename=\""+path.Base(info.Path)+"\"")
w.Header().Set(net.HeaderETag, info.Etag)
w.Header().Set(net.HeaderOCFileID, storagespace.FormatResourceID(*info.Id))
w.Header().Set(net.HeaderOCETag, info.Etag)
Expand Down
37 changes: 31 additions & 6 deletions internal/http/services/owncloud/ocdav/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind"
"github.com/cs3org/reva/v2/pkg/storagespace"
rtrace "github.com/cs3org/reva/v2/pkg/trace"
"github.com/cs3org/reva/v2/pkg/utils"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -71,12 +72,36 @@ func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler
h.doListVersions(w, r, s, rid)
return
}
if key != "" && r.Method == MethodCopy {
// TODO(jfd) it seems we cannot directly GET version content with cs3 ...
// TODO(jfd) cs3api has no delete file version call
// TODO(jfd) restore version to given Destination, but cs3api has no destination
h.doRestore(w, r, s, rid, key)
return
if key != "" {
switch r.Method {
case MethodCopy:
// TODO(jfd) cs3api has no delete file version call
// TODO(jfd) restore version to given Destination, but cs3api has no destination
h.doRestore(w, r, s, rid, key)
return
case http.MethodHead:
log := appctx.GetLogger(ctx)
ref := &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: rid.StorageId,
OpaqueId: key,
},
Path: utils.MakeRelativePath(r.URL.Path),
}
s.handleHead(ctx, w, r, ref, *log)
return
case http.MethodGet:
log := appctx.GetLogger(ctx)
ref := &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: rid.StorageId,
OpaqueId: key,
},
Path: utils.MakeRelativePath(r.URL.Path),
}
s.handleGet(ctx, w, r, ref, "spaces", *log)
return
}
}

http.Error(w, "501 Forbidden", http.StatusNotImplemented)
Expand Down
2 changes: 0 additions & 2 deletions tests/acceptance/expected-failures-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1421,8 +1421,6 @@ _ocs: api compatibility, return correct status code_
- [apiWebdavProperties1/copyFile.feature:484](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties1/copyFile.feature#L484)

#### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261)
- [apiVersions/fileVersions.feature:444](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L444)
- [apiVersions/fileVersions.feature:462](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L462)
- [apiVersions/fileVersionsSharingToShares.feature:306](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L306)

#### [file versions do not report the version author](https://github.com/owncloud/ocis/issues/2914)
Expand Down
2 changes: 0 additions & 2 deletions tests/acceptance/expected-failures-on-S3NG-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Basic file management like up and download, move, copy, properties, quota, trash
- [apiTrashbin/trashbinFilesFolders.feature:291](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiTrashbin/trashbinFilesFolders.feature#L291)

#### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261)
- [apiVersions/fileVersions.feature:444](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L444)
- [apiVersions/fileVersions.feature:462](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L462)
- [apiVersions/fileVersionsSharingToShares.feature:306](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L306)

#### [file versions do not report the version author](https://github.com/owncloud/ocis/issues/2914)
Expand Down