Use Folder Get Function for Permissions

This commit is contained in:
Samuel Lorch 2021-09-16 14:18:01 +02:00
parent 7e96b96c36
commit 9bceb71ed2

View file

@ -126,12 +126,14 @@ func ShareFolderWithUsersAndGroups(ctx context.Context, c *api.Client, folderID
// ShareFolder Shares a Folder as Specified in the Passed ShareOperation Struct Slice. // ShareFolder Shares a Folder as Specified in the Passed ShareOperation Struct Slice.
// Note Resources Permissions in the Folder are not Adjusted // Note Resources Permissions in the Folder are not Adjusted
func ShareFolder(ctx context.Context, c *api.Client, folderID string, changes []ShareOperation) error { func ShareFolder(ctx context.Context, c *api.Client, folderID string, changes []ShareOperation) error {
oldPermissions, err := c.GetFolderPermissions(ctx, folderID) oldFolder, err := c.GetFolder(ctx, folderID, &api.GetFolderOptions{
ContainPermissions: true,
})
if err != nil { if err != nil {
return fmt.Errorf("Getting Folder Permissions: %w", err) return fmt.Errorf("Getting Folder Permissions: %w", err)
} }
permissionChanges, err := GeneratePermissionChanges(oldPermissions, changes) permissionChanges, err := GeneratePermissionChanges(oldFolder.Permissions, changes)
if err != nil { if err != nil {
return fmt.Errorf("Generating Folder Permission Changes: %w", err) return fmt.Errorf("Generating Folder Permission Changes: %w", err)
} }