From d034e1013ca9429fa2284c0fd3612864d643bffe Mon Sep 17 00:00:00 2001 From: Chuck Daniels Date: Mon, 13 May 2024 10:27:17 -0400 Subject: [PATCH] Create dest dir for direct access before download Fixes #562 --- CHANGELOG.md | 3 +++ earthaccess/store.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99d9e86..6a1f50e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ * Bug fixes: * fixed 483 by extracting a common CMR query method for collections and granules using SearchAfter header * Added VCR support for verifying the API call to CMR and the parsing of returned results without relying on CMR availability post development + * [#562](https://github.com/nsidc/earthaccess/issues/562): The destination + path is now created prior to direct S3 downloads, if it doesn't already + exist. * Enhancements: * Corrected and enhanced static type hints for functions and methods that make diff --git a/earthaccess/store.py b/earthaccess/store.py index 67ff0c65..e56e9849 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -571,6 +571,9 @@ def _get_granules( else: print(f"Accessing cloud dataset using provider: {provider}") s3_fs = self.get_s3fs_session(provider=provider) + + local_path.mkdir(parents=True, exist_ok=True) + # TODO: make this async for file in data_links: s3_fs.get(file, str(local_path))