diff --git a/fsconnectors/asyncio/s3.py b/fsconnectors/asyncio/s3.py index 93d9e62..f65a957 100644 --- a/fsconnectors/asyncio/s3.py +++ b/fsconnectors/asyncio/s3.py @@ -200,4 +200,7 @@ async def upload_fileobj( @staticmethod def _split_path(path: str) -> list[str]: path = path.split('://')[-1] - return path.split('/', maxsplit=1) + parts = path.split('/', maxsplit=1) + if len(parts) == 1: + parts.append('') + return parts diff --git a/fsconnectors/cli.py b/fsconnectors/cli.py index 64988c6..d310d2e 100644 --- a/fsconnectors/cli.py +++ b/fsconnectors/cli.py @@ -134,6 +134,7 @@ async def download( Error files. """ s3_path, local_path = self._prepare_paths(s3_path, local_path) + print(s3_path, local_path) async with self.local_connector.connect() as lc: async with self.s3_connector.connect() as sc: files = await sc.scandir(s3_path, recursive=True) @@ -326,7 +327,7 @@ async def _download_file( def _prepare_paths(s3_path: str, local_path: str) -> tuple[str, str]: if platform.system() == 'Windows': local_path = re.sub(r'\\+', '/', local_path) - s3_path = s3_path.rstrip('/') + s3_path = s3_path.split('://')[-1].rstrip('/') local_path = local_path.rstrip('/') return s3_path, local_path diff --git a/fsconnectors/s3.py b/fsconnectors/s3.py index fb1daad..4c0bfbc 100644 --- a/fsconnectors/s3.py +++ b/fsconnectors/s3.py @@ -194,4 +194,7 @@ def _get_client(self) -> Any: @staticmethod def _split_path(path: str) -> list[str]: path = path.split('://')[-1] - return path.split('/', maxsplit=1) + parts = path.split('/', maxsplit=1) + if len(parts) == 1: + parts.append('') + return parts