Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-SFTP File Closing Behaviour #114

Open
NavindrenBaskaran opened this issue Sep 1, 2020 · 1 comment
Open

NET-SFTP File Closing Behaviour #114

NavindrenBaskaran opened this issue Sep 1, 2020 · 1 comment

Comments

@NavindrenBaskaran
Copy link

NavindrenBaskaran commented Sep 1, 2020

First Approach

file = sftp.file.open('remote/test.csv')
file.read

With this approach after the read is perform, the file still exists in the SFTP Server.

Second Approach

sftp.file.open('remote/test.csv') do |file|
  file.read
end

With this approach at the end of the block, the file is no longer in the SFTP Server, would like to understand why it works as such.

Looking at the code, for the second approach, we are ensuring that the file is always closed once the block is executed, hence the question is why does closing the file removes it from the server?

Thank you!

@Raaghulsundar
Copy link

Hey team! any help on this would be very much appreciated 🙏. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants