Use a hash for directory lookups

This commit is contained in:
Seth Vargo 2016-03-17 20:48:08 -05:00
parent a27e7e106a
commit 76e7a980a8
1 changed files with 6 additions and 4 deletions

View File

@ -106,7 +106,7 @@ module VagrantPlugins
def initialize(*)
require "net/sftp"
super
@dirs = []
@dirs = {}
end
def default_port
@ -125,10 +125,12 @@ 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