From 76e7a980a87cf2dcfe582c04ed3255d71aaaaa95 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 17 Mar 2016 20:48:08 -0500 Subject: [PATCH] Use a hash for directory lookups --- plugins/pushes/ftp/adapter.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/pushes/ftp/adapter.rb b/plugins/pushes/ftp/adapter.rb index f02ed1699..731816f01 100644 --- a/plugins/pushes/ftp/adapter.rb +++ b/plugins/pushes/ftp/adapter.rb @@ -106,7 +106,7 @@ module VagrantPlugins def initialize(*) require "net/sftp" super - @dirs = [] + @dirs = {} end def default_port @@ -125,16 +125,18 @@ module VagrantPlugins fullpath = Pathname.new(dir) fullpath.descend do |path| - if !@dirs.include?(path.to_s) - @dirs.push(path.to_s) # Cache visited directories in a list to avoid duplicate requests + if @dirs[path.to_s].nil? begin @server.mkdir!(path.to_s) + + # Cache visited directories in a list to avoid duplicate requests + @dirs[path.to_s] = true rescue Net::SFTP::StatusException => e # Directory exists, skip... end end end - + @server.upload!(local, remote) end end