From f6f2cc2e0c7a8d00b337f7989c14f86b77e6e610 Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Wed, 31 Mar 2021 16:35:43 +0200 Subject: [PATCH 1/5] allow full paths targets --- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index c62a3409df..a3866ffd9e 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -702,11 +702,12 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { if data.State == ocsStateAccepted { // Needed because received shares can be jailed in a folder in the users home - data.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path)) - data.Path = path.Join(h.sharePrefix, path.Base(info.Path)) + data.FileTarget = path.Join(h.sharePrefix, info.Path) + data.Path = path.Join(h.sharePrefix, info.Path) } shares = append(shares, data) + log.Info().Msgf("listSharesWithMe: %+v", *data) } response.WriteOCSSuccess(w, r, shares) @@ -844,7 +845,7 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf // TODO Storage: int s.ItemSource = wrapResourceID(info.Id) s.FileSource = s.ItemSource - s.FileTarget = path.Join("/", path.Base(info.Path)) + s.FileTarget = path.Join("/", info.Path) s.Path = path.Join("/", path.Base(info.Path)) // TODO hm this might have to be relative to the users home ... depends on the webdav_namespace config // TODO FileParent: // item type From 576bc4e2f5dd7fe68b224566436377d427a8110e Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Wed, 31 Mar 2021 16:49:36 +0200 Subject: [PATCH 2/5] add changelog --- changelog/unreleased/fix-sharing-paths.md | 6 ++++++ .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-sharing-paths.md diff --git a/changelog/unreleased/fix-sharing-paths.md b/changelog/unreleased/fix-sharing-paths.md new file mode 100644 index 0000000000..c59bc5c38a --- /dev/null +++ b/changelog/unreleased/fix-sharing-paths.md @@ -0,0 +1,6 @@ +Bugfix: Allow to expose full paths in OCS API + +Before this fix a share file_target was always harcoded to use a base path. +This fix provides the possiblity to expose full paths in the OCIS API and asymptotically in OCIS web. + +https://github.com/cs3org/reva/pull/1605 diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index a3866ffd9e..f998a93370 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -707,7 +707,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { } shares = append(shares, data) - log.Info().Msgf("listSharesWithMe: %+v", *data) + log.Debug().Msgf("listSharesWithMe: %+v", *data) } response.WriteOCSSuccess(w, r, shares) From 4a6e232da8e1ed148594c7f64d1ad0072c25629e Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Thu, 1 Apr 2021 13:36:29 +0200 Subject: [PATCH 3/5] fix logic --- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index f998a93370..c9bd09ff61 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -638,17 +638,16 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc ListReceivedShares request failed", err) return } - lrsRes.GetShares() shares := make([]*conversions.ShareData, 0) var info *provider.ResourceInfo // TODO(refs) filter out "invalid" shares for _, rs := range lrsRes.GetShares() { - if stateFilter != ocsStateUnknown && rs.GetState() != stateFilter { continue } + if pinfo != nil { // check if the shared resource matches the path resource if rs.Share.ResourceId.StorageId != pinfo.GetId().StorageId || @@ -845,8 +844,8 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf // TODO Storage: int s.ItemSource = wrapResourceID(info.Id) s.FileSource = s.ItemSource - s.FileTarget = path.Join("/", info.Path) - s.Path = path.Join("/", path.Base(info.Path)) // TODO hm this might have to be relative to the users home ... depends on the webdav_namespace config + s.FileTarget = path.Join("/", path.Base(info.Path)) + s.Path = path.Join("/", info.Path) // TODO hm this might have to be relative to the users home ... depends on the webdav_namespace config // TODO FileParent: // item type s.ItemType = conversions.ResourceType(info.GetType()).String() From f3b7a97941228c3e7498eab8c3a4ad72953bf8ba Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Thu, 1 Apr 2021 16:20:44 +0200 Subject: [PATCH 4/5] more fixes --- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index c9bd09ff61..46a1251020 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -701,12 +701,12 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { if data.State == ocsStateAccepted { // Needed because received shares can be jailed in a folder in the users home - data.FileTarget = path.Join(h.sharePrefix, info.Path) + data.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path)) data.Path = path.Join(h.sharePrefix, info.Path) } shares = append(shares, data) - log.Debug().Msgf("listSharesWithMe: %+v", *data) + log.Debug().Msgf("share: %+v", *data) } response.WriteOCSSuccess(w, r, shares) From 0a22ecadb40a02bb71ef5f1ca8917f14d0ca0eb1 Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Tue, 6 Apr 2021 10:47:11 +0200 Subject: [PATCH 5/5] use full paths for file target --- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 46a1251020..e3f3e42cb4 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -701,7 +701,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { if data.State == ocsStateAccepted { // Needed because received shares can be jailed in a folder in the users home - data.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path)) + data.FileTarget = path.Join(h.sharePrefix, info.Path) data.Path = path.Join(h.sharePrefix, info.Path) } @@ -844,8 +844,8 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf // TODO Storage: int s.ItemSource = wrapResourceID(info.Id) s.FileSource = s.ItemSource - s.FileTarget = path.Join("/", path.Base(info.Path)) - s.Path = path.Join("/", info.Path) // TODO hm this might have to be relative to the users home ... depends on the webdav_namespace config + s.FileTarget = path.Join("/", info.Path) + s.Path = path.Join("/", info.Path) // TODO FileParent: // item type s.ItemType = conversions.ResourceType(info.GetType()).String()