apiTest-coverage for #1523 (#1660)

* apiTest-coverage for #1523

* check propfind contans correct files name

* bump reva for getting #381
This commit is contained in:
Viktor Scharf
2025-10-24 09:45:03 +02:00
committed by GitHub
parent d76cacd99f
commit 44ee182aa3
8 changed files with 116 additions and 11 deletions

View File

@@ -186,7 +186,7 @@ func (s *service) getWebdavProtocol(ctx context.Context, share *ocm.Share, m *oc
return &ocmd.WebDAV{
Permissions: perms,
URL: s.webdavURL(ctx, share),
URI: s.webdavURL(ctx, share),
SharedSecret: share.Token,
}
}

View File

@@ -47,7 +47,37 @@ type Protocol interface {
type WebDAV struct {
SharedSecret string `json:"sharedSecret" validate:"required"`
Permissions []string `json:"permissions" validate:"required,dive,required,oneof=read write share"`
URL string `json:"url" validate:"required"`
URI string `json:"uri" validate:"required"`
}
// UnmarshalJSON implements custom JSON unmarshaling for backward compatibility.
// It supports both "url" (legacy) and "uri" (new) field names.
func (w *WebDAV) UnmarshalJSON(data []byte) error {
// Define a temporary struct with both url and uri fields
type WebDAVAlias struct {
SharedSecret string `json:"sharedSecret"`
Permissions []string `json:"permissions"`
URL string `json:"url"`
URI string `json:"uri"`
}
var alias WebDAVAlias
if err := json.Unmarshal(data, &alias); err != nil {
return err
}
// Copy common fields
w.SharedSecret = alias.SharedSecret
w.Permissions = alias.Permissions
// Use URI if present, otherwise fall back to URL for backward compatibility
if alias.URI != "" {
w.URI = alias.URI
} else {
w.URI = alias.URL
}
return nil
}
// ToOCMProtocol convert the protocol to a ocm Protocol struct.
@@ -76,7 +106,7 @@ func (w *WebDAV) ToOCMProtocol() *ocm.Protocol {
}
}
return ocmshare.NewWebDAVProtocol(w.URL, w.SharedSecret, perms)
return ocmshare.NewWebDAVProtocol(w.URI, w.SharedSecret, perms)
}
// Webapp contains the parameters for the Webapp protocol.

View File

@@ -32,6 +32,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/opencloud-eu/reva/v2/pkg/errtypes"
"github.com/opencloud-eu/reva/v2/pkg/storage"
"github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/lookup"
@@ -338,10 +339,12 @@ func (tb *Trashbin) RestoreRecycleItem(ctx context.Context, spaceID string, key,
return nil, fmt.Errorf("trashbin: parent id not found for %s", restorePath)
}
trashNode := &trashNode{spaceID: spaceID, id: id, path: trashPath}
err = tb.lu.MetadataBackend().Set(ctx, trashNode, prefixes.ParentidAttr, []byte(parentID))
if err != nil {
return nil, err
trashedNode := &trashNode{spaceID: spaceID, id: id, path: trashPath}
if err = tb.lu.MetadataBackend().SetMultiple(ctx, trashedNode, map[string][]byte{
prefixes.NameAttr: []byte(filepath.Base(restorePath)),
prefixes.ParentidAttr: []byte(parentID),
}, true); err != nil {
return nil, fmt.Errorf("posixfs: failed to update trashed node metadata: %w", err)
}
// restore the item