Skip to content

Commit

Permalink
fix: download destination path
Browse files Browse the repository at this point in the history
fix: s3 split path bucket root
  • Loading branch information
ShoytovMA committed Apr 12, 2024
1 parent ea37805 commit 76459c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion fsconnectors/asyncio/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion fsconnectors/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion fsconnectors/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 76459c3

Please sign in to comment.