Skip to content

Commit

Permalink
make share_prefix determine paths
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored and David Christofas committed Sep 9, 2021
1 parent 431cd50 commit 1e59246
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -793,9 +798,18 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf
// TODO Storage: int
s.ItemSource = wrapResourceID(info.Id)
s.FileSource = s.ItemSource
switch {
case s.ShareType == conversions.ShareTypePublicLink:
s.FileTarget = path.Join("/", path.Base(info.Path))
s.Path = path.Join("/", path.Base(info.Path))
case h.sharePrefix == "/":
s.FileTarget = path.Join("/", path.Base(info.Path))
s.Path = path.Join("/", path.Base(info.Path))
default:
s.FileTarget = path.Join(h.sharePrefix, path.Base(info.Path))
s.Path = path.Join("/", path.Base(info.Path))
}
s.StorageID = storageIDPrefix + s.FileTarget
s.FileTarget = path.Join("/", info.Path)
s.Path = path.Join("/", info.Path)
// TODO FileParent:
// item type
s.ItemType = conversions.ResourceType(info.GetType()).String()
Expand Down

0 comments on commit 1e59246

Please sign in to comment.