From 627a0b192692e57d60c3a6ef53063cd2eb5f92bd Mon Sep 17 00:00:00 2001 From: buddhhu Date: Tue, 19 Sep 2023 22:33:40 +0530 Subject: [PATCH] return on error --- utilities/gdrive.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utilities/gdrive.py b/utilities/gdrive.py index 36dc5d9a42..367bc4bc9b 100644 --- a/utilities/gdrive.py +++ b/utilities/gdrive.py @@ -216,7 +216,9 @@ async def list_files(self, query: str = None) -> list: params=params, ) ).json() - for file in resp.get("files", []): + if "error" in resp: + return resp + for file in resp.get("files"): if file["mimeType"] == self.folder_mime: file["url"] = self._create_folder_link(file["id"]) else: @@ -314,10 +316,7 @@ async def upload_file( data=json.dumps(params), params={"fields": "id, name, webContentLink"}, ) - if r.status == 401: - await self._refresh_access_token() - return await self.upload_file(event, path, filename, folder_id) - elif r.status == 403: + if r.status == 403: # upload to root and move r = await self.upload_file(event, path, filename, "root") return await self.copy_file(r["id"], filename, folder_id, move=True)