fix for file.list api pagination
This commit is contained in:
@ -6,6 +6,7 @@ from unicodedata import normalize
|
||||
from mdrsclient.api import FilesApi, FoldersApi
|
||||
from mdrsclient.commands.base import BaseCommand
|
||||
from mdrsclient.exceptions import IllegalArgumentException
|
||||
from mdrsclient.models.file import find_file
|
||||
|
||||
|
||||
class CpCommand(BaseCommand):
|
||||
@ -46,11 +47,13 @@ class CpCommand(BaseCommand):
|
||||
connection = cls._create_connection(s_remote)
|
||||
laboratory = cls._find_laboratory(connection, s_laboratory_name)
|
||||
s_parent_folder = cls._find_folder(connection, laboratory, s_dirname)
|
||||
s_parent_files = cls._find_files(connection, s_parent_folder.id)
|
||||
d_parent_folder = cls._find_folder(connection, laboratory, d_dirname)
|
||||
s_file = s_parent_folder.find_file(s_basename)
|
||||
d_parent_files = cls._find_files(connection, d_parent_folder.id)
|
||||
s_file = find_file(s_parent_files, s_basename)
|
||||
if s_file is not None:
|
||||
# source is file
|
||||
d_file = d_parent_folder.find_file(d_basename)
|
||||
d_file = find_file(d_parent_files, d_basename)
|
||||
if d_file is not None:
|
||||
raise IllegalArgumentException(f"File `{d_basename}` already exists.")
|
||||
d_sub_folder = d_parent_folder.find_sub_folder(d_basename)
|
||||
@ -66,7 +69,7 @@ class CpCommand(BaseCommand):
|
||||
# source is folder
|
||||
if not is_recursive:
|
||||
raise IllegalArgumentException(f"Cannot copy `{s_path}`: Is a folder.")
|
||||
if d_parent_folder.find_file(d_basename) is not None:
|
||||
if find_file(d_parent_files, d_basename) is not None:
|
||||
raise IllegalArgumentException(f"Cannot overwrite non-folder `{d_basename}` with folder `{s_path}`.")
|
||||
d_folder = d_parent_folder.find_sub_folder(d_basename)
|
||||
if d_folder is not None:
|
||||
|
Reference in New Issue
Block a user