From cacdde4d141d85a7eb5a37c8dd8e8bc9614997ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 28 May 2021 08:21:39 +0000 Subject: [PATCH] make share_prefix determine paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../handlers/apps/sharing/shares/shares.go | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 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 c4824fbc61f..f2d835f8c42 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 @@ -645,11 +645,16 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { // if we are in a jail and the current share has been accepted use the stat from the share jail // Needed because received shares can be jailed in a folder in the users home - // if we have share jail infos use them to build the path - if sji := findMatch(shareJailInfos, rs.Share.ResourceId); sji != nil { - // override path with info from share jail - data.FileTarget = path.Join(h.sharePrefix, path.Base(sji.Path)) - data.Path = path.Join(h.sharePrefix, path.Base(sji.Path)) + if h.sharePrefix != "/" { + // if we have share jail infos use them to build the path + if sji := findMatch(shareJailInfos, rs.Share.ResourceId); sji != nil { + // override path with info from share jail + data.FileTarget = path.Join(h.sharePrefix, path.Base(sji.Path)) + data.Path = path.Join(h.sharePrefix, path.Base(sji.Path)) + } else { + data.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path)) + data.Path = path.Join(h.sharePrefix, path.Base(info.Path)) + } } else { data.FileTarget = info.Path data.Path = info.Path @@ -794,8 +799,13 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf s.ItemSource = wrapResourceID(info.Id) s.FileSource = s.ItemSource s.StorageID = storageIDPrefix + s.FileTarget - s.FileTarget = path.Join("/", info.Path) - s.Path = path.Join("/", info.Path) + if h.sharePrefix != "/" { + s.FileTarget = path.Join("/", path.Base(info.Path)) + s.Path = path.Join("/", path.Base(info.Path)) + } else { + s.FileTarget = path.Join("/", info.Path) + s.Path = path.Join("/", info.Path) + } // TODO FileParent: // item type s.ItemType = conversions.ResourceType(info.GetType()).String()