real path should not be used when creating distination file list.
This commit is contained in:
parent
292ca1df27
commit
9284346153
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from typing import Any, Final
|
||||
|
||||
from pydantic import TypeAdapter
|
||||
@ -31,7 +32,7 @@ class FilesApi(BaseApi):
|
||||
token_check(self.connection)
|
||||
data: dict[str, str | int] = {"folder_id": folder_id}
|
||||
try:
|
||||
with open(path, mode="rb") as fp:
|
||||
with open(os.path.relpath(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())
|
||||
@ -46,7 +47,7 @@ class FilesApi(BaseApi):
|
||||
if path is not None:
|
||||
# update file body
|
||||
try:
|
||||
with open(path, mode="rb") as fp:
|
||||
with open(os.path.relpath(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 = os.path.realpath(local_path)
|
||||
l_path = local_path
|
||||
if not os.path.exists(l_path):
|
||||
raise IllegalArgumentException(f"File or directory `{local_path}` not found.")
|
||||
connection = cls._create_connection(remote)
|
||||
@ -55,8 +55,7 @@ class UploadCommand(BaseCommand):
|
||||
folder_map[r_path] = folder
|
||||
l_basename = os.path.basename(l_path)
|
||||
for dirpath, _, filenames in os.walk(l_path):
|
||||
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_dirname = os.path.join(r_path, l_basename)
|
||||
d_basename = os.path.basename(d_dirname)
|
||||
# prepare destination parent path
|
||||
d_parent_dirname = os.path.dirname(d_dirname)
|
||||
|
Loading…
Reference in New Issue
Block a user