lib/vos/drivers/ssh_vfs_storage.rb in vos-0.1.3 vs lib/vos/drivers/ssh_vfs_storage.rb in vos-0.1.4

- old
+ new

@@ -9,10 +9,14 @@ stat = sftp.stat! fix_path(path) attrs = {} attrs[:file] = stat.file? attrs[:dir] = stat.directory? # stat.symlink? + + # attributes special for file system + attrs[:updated_at] = stat.mtime + attrs rescue Net::SFTP::StatusException {} end @@ -77,28 +81,30 @@ def delete_dir path exec "rm -r #{path}" end - def each path, &block + def each_entry path, &block sftp.dir.foreach path do |stat| next if stat.name == '.' or stat.name == '..' if stat.directory? block.call stat.name, :dir else block.call stat.name, :file end end end - def efficient_dir_copy from, to + def efficient_dir_copy from, to, override + return false if override # sftp doesn't support this behaviour + from.storage.open_fs do |from_fs| to.storage.open_fs do |to_fs| if from_fs.local? sftp.upload! from.path, fix_path(to.path) true elsif to_fs.local? - sftp.download! fix_path(to.path), from.path, :recursive => true + sftp.download! fix_path(from.path), to.path, :recursive => true true else false end end \ No newline at end of file