Skip to content

Commit

Permalink
return on error
Browse files Browse the repository at this point in the history
  • Loading branch information
buddhhu committed Sep 19, 2023
1 parent e1e65f4 commit 627a0b1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions utilities/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 627a0b1

Please sign in to comment.