@@ -58,13 +58,40 @@ async def push(self, src, dest, mode=0o644, progress=None):
5858 for item in files :
5959 await self ._push (root / item , destdir / item , mode , progress )
6060
61- async def pull (self , src , dest ):
61+ async def _pull (self , src , dest ):
6262 sync_conn = await self .sync ()
6363 sync = SyncAsync (sync_conn )
6464
6565 async with sync_conn :
6666 return await sync .pull (src , dest )
6767
68+ async def pull (self , src , dest ):
69+ src = PurePosixPath (src )
70+ dest = Path (dest )
71+
72+ dir_string = "IS_DIR"
73+ res = await self .shell (f"[ -d { src } ] && echo { dir_string } " )
74+ if dir_string in res :
75+ # Get all files in the dir
76+ # Pull each
77+ dest .mkdir (exist_ok = True )
78+ cmd = f"ls -1a { src } "
79+ res = await self .shell (cmd )
80+ contents_list = res .split ("\n " )
81+ contents_list = [
82+ x for x in contents_list if x != "." and x != ".." and x != ""
83+ ]
84+ for element in contents_list :
85+ element_src = src / element
86+ element_dest = dest / element
87+ await self .pull (element_src , element_dest )
88+ else :
89+ file_string = "IS_FILE"
90+ res = await self .shell (f"[ -f { src } ] && echo { file_string } " )
91+ if file_string not in res :
92+ raise FileNotFoundError (f"Cannot find { src } on device" )
93+ await self ._pull (str (src ), str (dest ))
94+
6895 async def install (
6996 self ,
7097 path ,
0 commit comments