From fcceff10960f6816be4469a2aeaae94fa4353edb Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Wed, 12 Jul 2023 21:11:01 +0900 Subject: [PATCH] use query with folder + title, instead of list all files then apply filters --- gdrive_ros/node_scripts/gdrive_server_node.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gdrive_ros/node_scripts/gdrive_server_node.py b/gdrive_ros/node_scripts/gdrive_server_node.py index e3ee2731e..bbdcd609d 100644 --- a/gdrive_ros/node_scripts/gdrive_server_node.py +++ b/gdrive_ros/node_scripts/gdrive_server_node.py @@ -252,15 +252,8 @@ def _get_parents_id(self, parents_path, parents_id=None, mkdir=False): folder_title = parents_path[0] parent = parents_id if parents_id else 'root' - gfiles = self.gdrive.ListFile( - {'q': "'{}' in parents and trashed=false".format(parent)}) - gfiles = gfiles.GetList() - gfolders = [] - for gf in gfiles: - if (gf['mimeType'] == self.folder_mime_type - and gf['title'] == folder_title): - gfolders.append(gf) - + gfolders = self.gdrive.ListFile( + {'q': "'{}' in parents and mimeType = '{}' and title = '{}' and trashed=false".format(parent, self.folder_mime_type, folder_title)}).GetList() if len(parents_path) == 1: if len(gfolders) > 0: return gfolders[0]['id']