Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use query to find folder + title, instead of list all files and apply fileters #481

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading