Open NachE opened 2 years ago
For my design, if a regular file is used as remoteDir
parameter, it should be normally downloaded into localDir
, and it actually did.
This error occurs because my scp implementation expects more incoming items from remote in recursive
transfer mode, but it only gets a io.EOF
(because the remote scp server exits after sending the only file).
Typically, incorrect usage or network problem could lead to such error. It sounds great to explicitly return io.ErrUnexpectedEOF
for the condition you descried.
Do you mind sending a PR to fix this issue? Many thanks !
The function
CopyDirFromRemote()
exites with EOF error if a regular file is used asremoteDir
parameter. This could be normal but the parameter "-r" in scp command from openssh can even download a regular file.Also, from io lib: Functions should return EOF only to signal a graceful end of input. If the EOF occurs unexpectedly in a structured data stream, the appropriate error is either ErrUnexpectedEOF or some other error giving more detail (https://pkg.go.dev/io#pkg-variables). I think that in that case, EOF is an expected signal.
Have you considered handle EOF error from (https://github.com/povsister/scp/blob/33febfd9f13ee526b1c25bfaa4d76f094dbb3212/protocol.go#L533) and allow using regular files with
CopyDirFromRemote()
function?