cloudpathlib icon indicating copy to clipboard operation
cloudpathlib copied to clipboard

fix: download_to function tried to download path files

Open yuriolive opened this issue 3 years ago • 0 comments

In download directory cases, the download_to function was running in an infinite loop. For example:

We have a s3 example bucket with 1 one file in it: s3://example/test_file.txt

The function iterdir() will return:

s3://example/
s3://example/test_file.txt

In this case the rel_dest variable will be an empty string for the first case and test_file.txt for the second one.

The f.download_to(destination / rel_dest) will call the download_to function with re_dest as empty, causing an infinite loop.

The solution was to just verify if re_dest is not empty.

I also added the parents=True to destination.mkdir so it will create the directory even if is missing intermediate parent directories.

yuriolive avatar Feb 05 '22 20:02 yuriolive