From 60594bbfd4a76c190c678ed5b7524f54248178dd Mon Sep 17 00:00:00 2001 From: Aaron Edwards Date: Mon, 11 Nov 2024 21:06:05 -0800 Subject: [PATCH 1/2] Fix for picklepete/pyicloud#384, picklepete/pyicloud#366 and picklepete/pyicloud#326 --- pyicloud/services/drive.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyicloud/services/drive.py b/pyicloud/services/drive.py index 87573ce6..31f91b48 100644 --- a/pyicloud/services/drive.py +++ b/pyicloud/services/drive.py @@ -157,6 +157,8 @@ def send_file(self, folder_id, file_object): def create_folders(self, parent, name): """Creates a new iCloud Drive folder""" + # when creating a folder on icloud.com, the clientID is set to the following: + temp_client_id = f"FOLDER::UNKNOWN_ZONE::TempId-{uuid.uuid4()}" request = self.session.post( self._service_root + "/createFolders", params=self.params, @@ -166,7 +168,7 @@ def create_folders(self, parent, name): "destinationDrivewsId": parent, "folders": [ { - "clientId": self.params["clientId"], + "clientId": temp_client_id, "name": name, } ], @@ -198,6 +200,8 @@ def rename_items(self, node_id, etag, name): def move_items_to_trash(self, node_id, etag): """Moves an iCloud Drive node to the trash bin""" + # when creating a folder on icloud.com, the clientID is set to the node_id: + temp_client_id = node_id request = self.session.post( self._service_root + "/moveItemsToTrash", params=self.params, @@ -207,7 +211,7 @@ def move_items_to_trash(self, node_id, etag): { "drivewsid": node_id, "etag": etag, - "clientId": self.params["clientId"], + "clientId": temp_client_id, } ], } From 89732abef4251f9a2a369bb5ba994c252d7d74fc Mon Sep 17 00:00:00 2001 From: Aaron Edwards Date: Mon, 11 Nov 2024 21:20:29 -0800 Subject: [PATCH 2/2] Quick comment cut-paste fix --- pyicloud/services/drive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyicloud/services/drive.py b/pyicloud/services/drive.py index 31f91b48..63065a48 100644 --- a/pyicloud/services/drive.py +++ b/pyicloud/services/drive.py @@ -200,7 +200,7 @@ def rename_items(self, node_id, etag, name): def move_items_to_trash(self, node_id, etag): """Moves an iCloud Drive node to the trash bin""" - # when creating a folder on icloud.com, the clientID is set to the node_id: + # when moving a node to the trash on icloud.com, the clientID is set to the node_id: temp_client_id = node_id request = self.session.post( self._service_root + "/moveItemsToTrash",