Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create local data directories if necessary #370

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pooch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,17 @@ def retrieve(
path = os_cache("pooch")
if fname is None:
fname = unique_file_name(url)
# Create the local data directory if it doesn't already exist and make the
# path absolute.
# Make the path absolute.
path = cache_location(path, env=None, version=None)
make_local_storage(path)

full_path = path.resolve() / fname
action, verb = download_action(full_path, known_hash)

if action in ("download", "update"):
# We need to write data, so create the local data directory if it
# doesn't already exist.
make_local_storage(path)

get_logger().info(
"%s data from '%s' to file '%s'.",
verb,
Expand Down Expand Up @@ -560,9 +562,6 @@ def fetch(self, fname, processor=None, downloader=None, progressbar=False):
"""
self._assert_file_in_registry(fname)

# Create the local data directory if it doesn't already exist
make_local_storage(str(self.abspath))

url = self.get_url(fname)
full_path = self.abspath / fname
known_hash = self.registry[fname]
Expand All @@ -574,6 +573,10 @@ def fetch(self, fname, processor=None, downloader=None, progressbar=False):
)

if action in ("download", "update"):
# We need to write data, so create the local data directory if it
# doesn't already exist.
make_local_storage(str(self.abspath))

get_logger().info(
"%s file '%s' from '%s' to '%s'.",
verb,
Expand Down
Loading