Skip to content

Commit

Permalink
Resolves #160
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Nov 13, 2024
1 parent 5e647fb commit ed92bec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Also adds a new ALFPath class to replace alf path functions.
- one.alf.path module containing ALFPath class
- ALF cache table generation has lower memory footprint
- setup in silent mode now uses defaults if base url matches default one
- bugfix: error downloading from http server with keep_uuids=True

### Added

Expand Down
8 changes: 5 additions & 3 deletions one/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,8 @@ def _download_dataset(
return
if isinstance(url, str):
target_dir = str(Path(cache_dir, alfiles.get_alf_path(url)).parent)
return self._download_file(url, target_dir, **kwargs)
file = self._download_file(url, target_dir, **kwargs)
return ALFPath(file) if file else None
# must be list of URLs
valid_urls = list(filter(None, url))
if not valid_urls:
Expand Down Expand Up @@ -2558,6 +2559,7 @@ def _tag_mismatched_file_record(self, url):
def _download_file(self, url, target_dir, keep_uuid=None, file_size=None, hash=None):
"""
Downloads a single file or multitude of files from an HTTP webserver.
The webserver in question is set by the AlyxClient object.
Parameters
Expand All @@ -2575,7 +2577,7 @@ def _download_file(self, url, target_dir, keep_uuid=None, file_size=None, hash=N
Returns
-------
one.alf.path.ALFPath or list of one.alf.path.ALFPath
pathlib.Path or list of pathlib.Path
The file path of the downloaded file or files.
Example
Expand All @@ -2599,7 +2601,7 @@ def _download_file(self, url, target_dir, keep_uuid=None, file_size=None, hash=N

# check if we are keeping the uuid on the list of file names
if keep_uuid is True or (keep_uuid is None and self.uuid_filenames):
return local_path
return list(local_path) if isinstance(local_path, tuple) else local_path

# remove uuids from list of file names
if isinstance(local_path, (list, tuple)):
Expand Down
3 changes: 2 additions & 1 deletion one/webclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ def download_file(self, url, **kwargs):
Returns
-------
Local path(s) of downloaded file(s).
pathlib.Path, list of pathlib.Path
Local path(s) of downloaded file(s).
"""
if isinstance(url, str):
url = self._validate_file_url(url)
Expand Down

0 comments on commit ed92bec

Please sign in to comment.