From e8a3f28cf0b2798e6ed89143516f457bfb7af5c8 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 26 Oct 2023 11:59:21 +0200 Subject: [PATCH] use existing mountpoint on auto accept Signed-off-by: jkoberg --- changelog/unreleased/fix-mountpoint-autoaccept.md | 5 +++++ services/frontend/pkg/command/events.go | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/fix-mountpoint-autoaccept.md diff --git a/changelog/unreleased/fix-mountpoint-autoaccept.md b/changelog/unreleased/fix-mountpoint-autoaccept.md new file mode 100644 index 0000000000..9a1abf7e4a --- /dev/null +++ b/changelog/unreleased/fix-mountpoint-autoaccept.md @@ -0,0 +1,5 @@ +Bugfix: set existing mountpoint on auto accept + +When already having a share for a specific resource, auto accept would use custom mountpoints which lead to other errors. Now auto-accept is using the existing mountpoint of a share. + +https://github.com/owncloud/ocis/pull/7592 diff --git a/services/frontend/pkg/command/events.go b/services/frontend/pkg/command/events.go index 341653513f..e238f607a6 100644 --- a/services/frontend/pkg/command/events.go +++ b/services/frontend/pkg/command/events.go @@ -162,11 +162,19 @@ func getMountpoint(ctx context.Context, itemid *provider.ResourceId, uid *user.U // we need to sort the received shares by mount point in order to make things easier to evaluate. base := path.Base(info.GetPath()) mount := base - var mountedShares []*collaboration.ReceivedShare + mountedShares := make([]*collaboration.ReceivedShare, 0, len(lrs.Shares)) for _, s := range lrs.Shares { - if !utils.ResourceIDEqual(s.Share.ResourceId, itemid) && s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED { - mountedShares = append(mountedShares, s) + if s.State != collaboration.ShareState_SHARE_STATE_ACCEPTED { + // we don't care about unaccepted shares + continue } + + if utils.ResourceIDEqual(s.Share.ResourceId, itemid) { + // a share to the same resource already exists and is mounted + return s.MountPoint.Path, nil + } + + mountedShares = append(mountedShares, s) } sort.Slice(mountedShares, func(i, j int) bool {