Skip to content

Commit

Permalink
Fix webdav file versions endpoint bugs (cs3org#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored and root committed Apr 20, 2021
1 parent 42b6af3 commit 8a74120
Show file tree
Hide file tree
Showing 9 changed files with 1,442 additions and 1,279 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix_file_versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix webdav file versions endpoint bugs

Etag and error code related bugs have been fixed for the webdav file versions endpoint and removed from the expected failures file.


https://github.com/cs3org/reva/pull/1526
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/cheggaaa/pb v1.0.29
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20210310133342-f4a10134033c
github.com/cs3org/go-cs3apis v0.0.0-20210316113645-e4a74cb8761c
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59
github.com/ffurano/grpc-proto v0.0.0-20210312134900-65801a1ca184
Expand Down
81 changes: 30 additions & 51 deletions go.sum

Large diffs are not rendered by default.

26 changes: 18 additions & 8 deletions internal/grpc/services/storageregistry/storageregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,38 @@ func (s *service) ListStorageProviders(ctx context.Context, req *registrypb.List
}, nil
}

providers := make([]*registrypb.ProviderInfo, 0, len(pinfos))
for _, info := range pinfos {
fill(info)
providers = append(providers, info)
}

res := &registrypb.ListStorageProvidersResponse{
Status: status.NewOK(ctx),
Providers: pinfos,
Providers: providers,
}
return res, nil
}

func (s *service) GetStorageProviders(ctx context.Context, req *registrypb.GetStorageProvidersRequest) (*registrypb.GetStorageProvidersResponse, error) {
p, err := s.reg.FindProviders(ctx, req.Ref)
func (s *service) GetStorageProvider(ctx context.Context, req *registrypb.GetStorageProviderRequest) (*registrypb.GetStorageProviderResponse, error) {
p, err := s.reg.FindProvider(ctx, req.Ref)
if err != nil {
switch err.(type) {
case errtypes.IsNotFound:
return &registrypb.GetStorageProvidersResponse{
return &registrypb.GetStorageProviderResponse{
Status: status.NewNotFound(ctx, err.Error()),
}, nil
default:
return &registrypb.GetStorageProvidersResponse{
return &registrypb.GetStorageProviderResponse{
Status: status.NewInternal(ctx, err, "error finding storage provider"),
}, nil
}
}

res := &registrypb.GetStorageProvidersResponse{
Status: status.NewOK(ctx),
Providers: p,
fill(p)
res := &registrypb.GetStorageProviderResponse{
Status: status.NewOK(ctx),
Provider: p,
}
return res, nil
}
Expand All @@ -154,3 +161,6 @@ func (s *service) GetHome(ctx context.Context, req *registrypb.GetHomeRequest) (
}
return res, nil
}

// TODO(labkode): fix
func fill(p *registrypb.ProviderInfo) {}
18 changes: 6 additions & 12 deletions internal/http/services/owncloud/ocdav/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

if rid == (*provider.ResourceId)(nil) {
http.Error(w, "404 Not Found", http.StatusNotFound)
return
}

// baseURI is encoded as part of the response payload in href field
baseURI := path.Join(ctx.Value(ctxKeyBaseURI).(string), wrapResourceID(rid))
ctx = context.WithValue(ctx, ctxKeyBaseURI, baseURI)
Expand Down Expand Up @@ -130,17 +135,6 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
// add version dir . entry, derived from file info
infos = append(infos, &provider.ResourceInfo{
Type: provider.ResourceType_RESOURCE_TYPE_CONTAINER,
Id: &provider.ResourceId{
StorageId: "virtual", // this is a virtual storage
OpaqueId: path.Join("meta", wrapResourceID(rid), "v"),
},
Etag: info.Etag,
MimeType: "httpd/unix-directory",
Mtime: info.Mtime,
Path: "v",
// PermissionSet
Size: 0,
Owner: info.Owner,
})

for i := range versions {
Expand All @@ -153,7 +147,7 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
OpaqueId: info.Id.OpaqueId + "@" + versions[i].GetKey(),
},
// Checksum
// Etag: v.ETag,
Etag: versions[i].Etag,
// MimeType
Mtime: &types.Timestamp{
Seconds: versions[i].Mtime,
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ func (fs *ocfs) filterAsRevision(ctx context.Context, bn string, md os.FileInfo)
Key: version,
Size: uint64(md.Size()),
Mtime: uint64(mtime),
Etag: calcEtag(ctx, md),
}
}
return nil
Expand Down
400 changes: 227 additions & 173 deletions tests/acceptance/expected-failures-on-OCIS-storage.md

Large diffs are not rendered by default.

440 changes: 261 additions & 179 deletions tests/acceptance/expected-failures-on-OWNCLOUD-storage.md

Large diffs are not rendered by default.

1,747 changes: 892 additions & 855 deletions tests/acceptance/expected-failures-on-S3NG-storage.md

Large diffs are not rendered by default.

0 comments on commit 8a74120

Please sign in to comment.