diff --git a/internal/grpc/services/usershareprovider/usershareprovider.go b/internal/grpc/services/usershareprovider/usershareprovider.go index c52caad51ba..ae5f0ea797f 100644 --- a/internal/grpc/services/usershareprovider/usershareprovider.go +++ b/internal/grpc/services/usershareprovider/usershareprovider.go @@ -506,24 +506,6 @@ func (s *service) GetReceivedShare(ctx context.Context, req *collaboration.GetRe } func (s *service) UpdateReceivedShare(ctx context.Context, req *collaboration.UpdateReceivedShareRequest) (*collaboration.UpdateReceivedShareResponse, error) { - if req.GetShare() == nil { - return &collaboration.UpdateReceivedShareResponse{ - Status: status.NewInvalid(ctx, "updating requires a received share object"), - }, nil - } - - if req.GetShare().GetShare() == nil { - return &collaboration.UpdateReceivedShareResponse{ - Status: status.NewInvalid(ctx, "share missing"), - }, nil - } - - if req.GetShare().GetShare().GetId() == nil { - return &collaboration.UpdateReceivedShareResponse{ - Status: status.NewInvalid(ctx, "share id missing"), - }, nil - } - if req.GetShare().GetShare().GetId().GetOpaqueId() == "" { return &collaboration.UpdateReceivedShareResponse{ Status: status.NewInvalid(ctx, "share id empty"), @@ -627,9 +609,7 @@ func GetAvailableMountpoint(ctx context.Context, gwc gateway.GatewayAPIClient, i return "", err } - // we need to sort the received shares by mount point in order to make things easier to evaluate. - base := filepath.Clean(name) - mount := base + mount := filepath.Clean(name) existingMountpoint := "" mountedShares := make([]string, 0, len(listReceivedSharesRes.GetShares())) var pathExists bool @@ -668,14 +648,9 @@ func GetAvailableMountpoint(ctx context.Context, gwc gateway.GatewayAPIClient, i if pathExists { // now we have a list of shares, we want to iterate over all of them and check for name collisions agents a mount points list for i := 1; i <= len(mountedShares)+1; i++ { - ext := filepath.Ext(base) - name := strings.TrimSuffix(base, ext) - // be smart about .tar.(gz|bz) files - if strings.HasSuffix(name, ".tar") { - name = strings.TrimSuffix(name, ".tar") - ext = ".tar" + ext - } - mount = name + " (" + strconv.Itoa(i) + ")" + ext + ext := filepath.Ext(mount) + mount = strings.TrimSuffix(mount, ext) + " (" + strconv.Itoa(i) + ")" + ext + if !slices.Contains(mountedShares, mount) { return mount, nil } diff --git a/internal/grpc/services/usershareprovider/usershareprovider_test.go b/internal/grpc/services/usershareprovider/usershareprovider_test.go index ba4ccf82108..9adcbef7788 100644 --- a/internal/grpc/services/usershareprovider/usershareprovider_test.go +++ b/internal/grpc/services/usershareprovider/usershareprovider_test.go @@ -141,30 +141,6 @@ var _ = Describe("user share provider service", func() { Expect(res.GetStatus().GetCode()).To(Equal(expectedStatus.GetCode())) Expect(res.GetStatus().GetMessage()).To(ContainSubstring(expectedStatus.GetMessage())) }, - Entry( - "no received share", - &collaborationpb.UpdateReceivedShareRequest{}, - status.NewInvalid(ctx, "updating requires"), - nil, - ), - Entry( - "no share", - &collaborationpb.UpdateReceivedShareRequest{ - Share: &collaborationpb.ReceivedShare{}, - }, - status.NewInvalid(ctx, "share missing"), - nil, - ), - Entry( - "no share id", - &collaborationpb.UpdateReceivedShareRequest{ - Share: &collaborationpb.ReceivedShare{ - Share: &collaborationpb.Share{}, - }, - }, - status.NewInvalid(ctx, "share id missing"), - nil, - ), Entry( "no share opaque id", &collaborationpb.UpdateReceivedShareRequest{