From ed92bec4c693f6746766ea028e1a44f4fd5c00bb Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Wed, 13 Nov 2024 13:21:20 +0200 Subject: [PATCH] Resolves #160 --- CHANGELOG.md | 1 + one/api.py | 8 +++++--- one/webclient.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60571e49..7302652f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/one/api.py b/one/api.py index 0118bef2..c77f146f 100644 --- a/one/api.py +++ b/one/api.py @@ -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: @@ -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 @@ -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 @@ -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)): diff --git a/one/webclient.py b/one/webclient.py index ef18ae0e..215a4f0e 100644 --- a/one/webclient.py +++ b/one/webclient.py @@ -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)