Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-10-13 14:50:18 +02:00
parent 78a56fc083
commit bfbba15fee

View File

@ -35,9 +35,12 @@ class GdriveSync(plugins.Plugin):
# Function to get the folder ID by its name # Function to get the folder ID by its name
def get_folder_id_by_name(self, drive, folder_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() 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: if 'files' in file_list and len(file_list['files']) > 0:
return file_list['files'][0]['id'] return file_list['files'][0]['id']
except Exception as e:
print(f"Error in get_folder_id_by_name: {e}")
return None return None
def on_loaded(self): def on_loaded(self):