Skip to content

Commit 7483c9f

Browse files
authored
Merge pull request #601 from RomaricKanyamibwa/master
Create subdir when downloading files
2 parents ceda42e + 1fb49e2 commit 7483c9f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/e3/net/http.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import e3.log
2020
import requests_toolbelt.multipart
2121
from e3.error import E3Error
22-
from e3.fs import rm
22+
from e3.fs import rm, mkdir
2323

2424
if TYPE_CHECKING:
2525
from types import TracebackType
@@ -314,6 +314,11 @@ def download_file(
314314

315315
path = os.path.join(dest, filename)
316316

317+
# create dest subdir if they do not exist
318+
dest_dir = os.path.dirname(path)
319+
if not os.path.exists(dest_dir):
320+
mkdir(dest_dir)
321+
317322
logger.info("downloading %s size=%s", path, content_length)
318323

319324
with open(path, "wb") as fd:

0 commit comments

Comments
 (0)