Skip to content

Commit

Permalink
Check if the dir exists before trying to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Itz-fork committed Jun 22, 2022
1 parent 4758a46 commit a0173fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gofile2/async_gofile2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ async def upload_folder(self, path: str, folderId: str = ""):
- `path` - Path to the folder
- `folderId` (optional) - The ID of a folder. When using the folderId, you must pass the token
"""
if not os.path.isdir(path):
raise InvalidPath(f"{path} is not a valid directory")
uploaded = []
files = [val for sublist in [[os.path.join(
i[0], j) for j in i[2]] for i in os.walk(path)] for val in sublist]
Expand Down
4 changes: 3 additions & 1 deletion gofile2/gofile2.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def upload_folder(self, path: str, folderId: str = ""):
- `path` - Path to the folder
- `folderId` (optional) - The ID of a folder. When using the folderId, you must pass the token
"""
if not os.path.isdir(path):
raise InvalidPath(f"{path} is not a valid directory")
uploaded = []
files = [val for sublist in [[os.path.join(
i[0], j) for j in i[2]] for i in os.walk(path)] for val in sublist]
Expand Down Expand Up @@ -120,7 +122,7 @@ def upload(self, file: str, folderId: str = None, description: str = None, passw
if not os.path.isfile(file):
raise InvalidPath(f"No such file - {file}")

token = self.token
token = self.token if self.token else ""
if password != None and len(password) < 4:
raise ValueError("Password Length must be greater than 4")

Expand Down

0 comments on commit a0173fe

Please sign in to comment.