bramvdbogaerde / go-scp

Simple Golang scp client
Mozilla Public License 2.0
424 stars 89 forks source link

CopyFromRemote can't throw file not found on remote, waill be hang #68

Closed EdgarDing77 closed 1 year ago

EdgarDing77 commented 1 year ago

if remote file not found, use CopyFromRemote will not throw file not found on remote, it will keep connection util timeout.

EdgarDing77 commented 1 year ago

test case base_test.go TestFileNotFound will be hang, test failed, it is bug?

T-TRz879 commented 1 year ago

yes,The Ack does return err, but the errChan does not return normally

T-TRz879 commented 1 year ago

I also found that files downloaded from a remote location will not exit with an error if the permission is not given locally

EdgarDing77 commented 1 year ago

I also found that files downloaded from a remote location will not exit with an error if the permission is not given locally

yes, if use os.OpenFile("./tmp/output_fnf.txt", os.O_CREATE|os.O_WRONLY, 0644) will not exit but os.Open can do it

T-TRz879 commented 1 year ago

I want to change it sometime

bramvdbogaerde commented 1 year ago

Thanks for opening this issue. Try to keep the discussion focussed on the original issue. I will try to confirm the failing test and keep you updated.

bramvdbogaerde commented 1 year ago

All tests succeed on my system (MacOS). Running ./run_all.sh in the tests directory I get:

Running from /Users/bram/sources/go-scp/tests
Starting docker containers
1af8e08b9cab1083c86b64c8a77d173e8d59eafc93446b1452dfad1660936932
Running tests
=== RUN   TestCopy
--- PASS: TestCopy (0.13s)
=== RUN   TestDownloadFile
--- PASS: TestDownloadFile (0.10s)
=== RUN   TestTimeoutDownload
--- PASS: TestTimeoutDownload (0.09s)
=== RUN   TestContextCancelDownload
--- PASS: TestContextCancelDownload (0.09s)
=== RUN   TestDownloadBadLocalFilePermissions
--- PASS: TestDownloadBadLocalFilePermissions (0.09s)
=== RUN   TestFileNotFound
--- PASS: TestFileNotFound (0.08s)
PASS
ok      github.com/bramvdbogaerde/go-scp/tests  0.702s
Tearing down docker containers
go-scp-test
go-scp-test
Cleaning up

@EdgarDing77 could you provide your full test output?

EdgarDing77 commented 1 year ago

if i try to copy testfile and run it, will failed, it will hang long time. In practical use, this is also the case。

TEST NEV:

DEV ENV:

=== RUN   TestDownloadFile
    basicscp_test.go:89: Couldn't open the output file

but if i fork this repo and run basic_test.go, it will ok, So strange.

=== RUN   TestDownloadFile
    basic_test.go:97: Copy failed from remote: scp: /input/Exöt1ç download file.txt.txt: No such file or directory
    basic_test.go:108: Got different text than expected, expected "It works for download!\n" got, ""
--- FAIL: TestDownloadFile (0.38s)
EdgarDing77 commented 1 year ago

I think I got it. Branch master is different from release v1.2.0 —— github.com/bramvdbogaerde/go-scp v1.2.0 You can check your source code between in release and master.

@bramvdbogaerde

EdgarDing77 commented 1 year ago

Can you release a new version to fix this? @bramvdbogaerde

bramvdbogaerde commented 1 year ago

New version has been released under the tag v1.2.1.