Skip to content

Commit

Permalink
use query to find folder + title, instead of list all files and apply…
Browse files Browse the repository at this point in the history
… fileters
  • Loading branch information
k-okada committed Jul 12, 2023
1 parent 97cc745 commit 4c004be
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions gdrive_ros/node_scripts/gdrive_server_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 4c004be

Please sign in to comment.