fixed bug to resolve local files for recursive file upload.
This commit is contained in:
parent
219858e0b6
commit
ce0a608db2
@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "0.2",
|
||||
"language": "en,en-gb",
|
||||
"ignoreWords": ["getframe", "pycache", "pydantic", "UNLCK"],
|
||||
"ignoreWords": ["followlinks", "getframe", "pycache", "pydantic", "UNLCK"],
|
||||
"words": [
|
||||
"chacl",
|
||||
"kikan",
|
||||
|
@ -1 +1 @@
|
||||
1.3.0
|
||||
1.3.1
|
||||
|
@ -32,7 +32,7 @@ class FilesApi(BaseApi):
|
||||
token_check(self.connection)
|
||||
data: dict[str, str | int] = {"folder_id": folder_id}
|
||||
try:
|
||||
with open(os.path.relpath(path), mode="rb") as fp:
|
||||
with open(os.path.realpath(path), mode="rb") as fp:
|
||||
response = self.connection.post(url, data=data, files={"file": fp})
|
||||
self._raise_response_error(response)
|
||||
ret = TypeAdapter(FilesApiCreateResponse).validate_python(response.json())
|
||||
@ -47,7 +47,7 @@ class FilesApi(BaseApi):
|
||||
if path is not None:
|
||||
# update file body
|
||||
try:
|
||||
with open(os.path.relpath(path), mode="rb") as fp:
|
||||
with open(os.path.realpath(path), mode="rb") as fp:
|
||||
response = self.connection.put(url, files={"file": fp})
|
||||
except OSError:
|
||||
raise UnexpectedException(f"Could not open `{path}` 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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "mdrs-client-python"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
description = "The mdrs-client-python is python library and a command-line client for up- and downloading files to and from MDRS based repository."
|
||||
authors = ["Yoshihiro OKUMURA <yoshihiro.okumura@riken.jp>"]
|
||||
license = "MIT"
|
||||
|
Loading…
Reference in New Issue
Block a user