fixed bug to resolve local files for recursive file upload.

This commit is contained in:
2023-12-20 19:42:06 +09:00
parent 219858e0b6
commit ce0a608db2
5 changed files with 9 additions and 8 deletions

View File

@ -40,7 +40,7 @@ class UploadCommand(BaseCommand):
@classmethod
def upload(cls, local_path: str, remote_path: str, is_recursive: bool) -> None:
(remote, laboratory_name, r_path) = cls._parse_remote_host_with_path(remote_path)
l_path = local_path
l_path = os.path.abspath(local_path)
if not os.path.exists(l_path):
raise IllegalArgumentException(f"File or directory `{local_path}` not found.")
connection = cls._create_connection(remote)
@ -54,8 +54,9 @@ class UploadCommand(BaseCommand):
folder_map: dict[str, Folder] = {}
folder_map[r_path] = folder
l_basename = os.path.basename(l_path)
for dirpath, _, filenames in os.walk(l_path):
d_dirname = os.path.join(r_path, l_basename)
for dirpath, _, filenames in os.walk(l_path, followlinks=True):
sub = l_basename if dirpath == l_path else os.path.join(l_basename, os.path.relpath(dirpath, l_path))
d_dirname = os.path.join(r_path, sub)
d_basename = os.path.basename(d_dirname)
# prepare destination parent path
d_parent_dirname = os.path.dirname(d_dirname)