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

Preserve modification and access times #95

Open
freayd opened this issue Aug 17, 2019 · 0 comments
Open

Preserve modification and access times #95

freayd opened this issue Aug 17, 2019 · 0 comments

Comments

@freayd
Copy link

freayd commented Aug 17, 2019

Hi there,

Could we add an option to download files while preserving their modification and access times? A flag recursive: true added to the method Net::SFTP::Session#download would be nice to have. It could work like the -p option of the sftp command line.

Here's my quick and dirty fix:

files = []
sftp.download!("destination", "local", recursive: true) do |event, downloader, *args|
  case event
  when :close then
    files << args[0]
  when :finish then
    files.each { |file| File.utime(sftp.stat!(file.remote).atime, sftp.stat!(file.remote).mtime, file.local) }
  end
end

I can work on a pull request if you support the idea.

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

1 participant