Use ensure_pathy for upload/download

This commit is contained in:
Adriane Boyd 2022-11-04 16:07:07 +01:00
parent 4b64c1bbcc
commit 1c2aae6117

View File

@ -337,6 +337,8 @@ def upload_file(src: Path, dest: Union[str, Path, "CloudPath"]) -> None:
src (Path): The source path. src (Path): The source path.
url (str): The destination URL to upload to. url (str): The destination URL to upload to.
""" """
dest = ensure_pathy(dest)
# Create parent directories for local paths # Create parent directories for local paths
if isinstance(dest, Path): if isinstance(dest, Path):
if not dest.parent.exists(): if not dest.parent.exists():
@ -357,6 +359,8 @@ def download_file(
force (bool): Whether to force download even if file exists. force (bool): Whether to force download even if file exists.
If False, the download will be skipped. If False, the download will be skipped.
""" """
src = ensure_pathy(src)
if dest.exists() and not force: if dest.exists() and not force:
return None return None
with src.open(mode="rb") as input_file: with src.open(mode="rb") as input_file: