Skip to content

Commit 9a4dd3e

Browse files
committed
review comment
1 parent 6539cbb commit 9a4dd3e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

singlestoredb/management/files.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ def download_file(
990990
*,
991991
overwrite: bool = False,
992992
encoding: Optional[str] = None,
993-
_skip_dir_check: bool = False,
994993
) -> Optional[Union[bytes, str]]:
995994
"""
996995
Download the content of a file path.
@@ -1011,6 +1010,45 @@ def download_file(
10111010
bytes or str - ``local_path`` is None
10121011
None - ``local_path`` is a Path or str
10131012
1013+
"""
1014+
return self._download_file(
1015+
path,
1016+
local_path=local_path,
1017+
overwrite=overwrite,
1018+
encoding=encoding,
1019+
_skip_dir_check=False,
1020+
)
1021+
1022+
def _download_file(
1023+
self,
1024+
path: PathLike,
1025+
local_path: Optional[PathLike] = None,
1026+
*,
1027+
overwrite: bool = False,
1028+
encoding: Optional[str] = None,
1029+
_skip_dir_check: bool = False,
1030+
) -> Optional[Union[bytes, str]]:
1031+
"""
1032+
Internal method to download the content of a file path.
1033+
1034+
Parameters
1035+
----------
1036+
path : Path or str
1037+
Path to the file
1038+
local_path : Path or str
1039+
Path to local file target location
1040+
overwrite : bool, optional
1041+
Should an existing file be overwritten if it exists?
1042+
encoding : str, optional
1043+
Encoding used to convert the resulting data
1044+
_skip_dir_check : bool, optional
1045+
Skip the directory check (internal use only)
1046+
1047+
Returns
1048+
-------
1049+
bytes or str - ``local_path`` is None
1050+
None - ``local_path`` is a Path or str
1051+
10141052
"""
10151053
if local_path is not None and not overwrite and os.path.exists(local_path):
10161054
raise OSError('target file already exists; use overwrite=True to replace')
@@ -1070,7 +1108,7 @@ def download_folder(
10701108
remote_path = os.path.join(path, rel_path)
10711109
target_file = os.path.normpath(os.path.join(local_path, rel_path))
10721110
os.makedirs(os.path.dirname(target_file), exist_ok=True)
1073-
self.download_file(remote_path, target_file, overwrite=overwrite, _skip_dir_check=True)
1111+
self._download_file(remote_path, target_file, overwrite=overwrite, _skip_dir_check=True)
10741112

10751113
def remove(self, path: PathLike) -> None:
10761114
"""

0 commit comments

Comments
 (0)