From f1abd0495c1eb9d08a80cf3bf1a03f9eea12f768 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Fri, 13 Oct 2023 14:57:46 +0200 Subject: [PATCH] v2.4.7 Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/plugins/default/gdrivesync.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pwnagotchi/plugins/default/gdrivesync.py b/pwnagotchi/plugins/default/gdrivesync.py index f2f53a0d..80acfe91 100644 --- a/pwnagotchi/plugins/default/gdrivesync.py +++ b/pwnagotchi/plugins/default/gdrivesync.py @@ -35,13 +35,11 @@ class GdriveSync(plugins.Plugin): # Function to get the folder ID by its name def get_folder_id_by_name(self, drive, folder_name): - try: - file_list = drive.ListFile({'q': "name="+folder_name+" and mimetype='application/vnd.google-apps.folder' and trashed=false"}).GetList() - if 'files' in file_list and len(file_list['files']) > 0: - return file_list['files'][0]['id'] - except Exception as e: - logging.error(f"Error in get_folder_id_by_name: {e}") - return None + file_list = drive.ListFile({'q': "mimeType='application/vnd.google-apps.folder' and trashed=false"}).GetList() + for file in file_list: + if file['title'] == folder_name: + return file['id'] + return None def on_loaded(self): # client_secrets.json needs to be not empty @@ -82,7 +80,7 @@ class GdriveSync(plugins.Plugin): print(f"Created folder '{backup_folder_name}' with ID: {backup_folder_id}") # Continue with the rest of the code using backup_folder_id - file_list = self.drive.ListFile({'q': f"name='{backup_folder_id}' and trashed=false"}).GetList() + file_list = self.drive.ListFile({'q': f"'{backup_folder_id}' and trashed=false"}).GetList() if not file_list: # Handle the case where no files were found