From 124ede7be87e124e08f2edf6c6adf5034095508c Mon Sep 17 00:00:00 2001 From: wobY <24554109+wobYY@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:27:50 +0200 Subject: [PATCH] Fixes: Issue #1507 --- gspread/client.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gspread/client.py b/gspread/client.py index e82e5be00..03a2b1779 100644 --- a/gspread/client.py +++ b/gspread/client.py @@ -329,6 +329,19 @@ def copy( for p in permissions: if p.get("deleted"): continue + + # .list_permissions() returns a list of permissions, + # even the folder permissions if the file is in a shared folder. + # We only want the permissions that are directly applied to the + # spreadsheet file, i.e. 'writer', 'commenter' and 'reader'. + perm_details = { + p_details.get("permissionType"): p_details.get("inherited") + for p_details in p.get("permissionDetails") + } + if p.get("role") in ("organizer", "fileOrganizer") and ( + perm_details.get("file") or perm_details.get("member") + ): + continue # In case of domain type the domain extract the domain # In case of user/group extract the emailAddress