From 136682e4c9ede6bb27eab80238c427be1c5abb8b Mon Sep 17 00:00:00 2001 From: Nikola Rasulic Date: Thu, 20 Feb 2025 08:08:34 +0000 Subject: [PATCH] fix branch depth for single file download --- solvebio/cli/data.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/solvebio/cli/data.py b/solvebio/cli/data.py index 08b394cc..cf3cba83 100644 --- a/solvebio/cli/data.py +++ b/solvebio/cli/data.py @@ -746,9 +746,11 @@ def _download_recursive( min_depth = min([x.depth for x in remote_objects]) num_at_min_depth = len([x for x in remote_objects if x.depth == min_depth]) - if num_at_min_depth == 1: + if num_at_min_depth == 1 and not _is_single_file(remote_objects): + # when downloading from folder base_folder_depth = min_depth else: + # when downloading from vault root or singular file base_folder_depth = min_depth - 1 downloaded_files = set() @@ -932,6 +934,10 @@ def _get_relative_download_path(base_path, path_to_object, filename): return filename +def _is_single_file(objects): + return len(objects) == 1 and objects[0].get("object_type") == "file" + + def ls(args): """ Given a SolveBio remote path, list the files and folders