diff --git a/gofile2/async_gofile2.py b/gofile2/async_gofile2.py index 4b1582a..1fb3502 100644 --- a/gofile2/async_gofile2.py +++ b/gofile2/async_gofile2.py @@ -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] diff --git a/gofile2/gofile2.py b/gofile2/gofile2.py index 2cac022..2e455b6 100644 --- a/gofile2/gofile2.py +++ b/gofile2/gofile2.py @@ -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] @@ -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")