fig 0.1.28 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/fig/os.rb +36 -7
  2. metadata +2 -2
data/lib/fig/os.rb CHANGED
@@ -34,6 +34,7 @@ module Fig
34
34
  else
35
35
  ftp.login()
36
36
  end
37
+ ftp.passive = true
37
38
  end
38
39
 
39
40
  def list(dir)
@@ -72,13 +73,10 @@ module Fig
72
73
  ftp = Net::FTP.new(uri.host)
73
74
  ftp_login(ftp)
74
75
  ftp.chdir(uri.path)
75
- packages = []
76
- ftp.retrlines('LIST -R .') do |line|
77
- parts = line.gsub(/\\/, '/').sub(/^\.\//, '').sub(/:$/, '').split('/')
78
- packages << parts.join('/') if parts.size == 2
79
- end
76
+ dirs = ftp.nlst
80
77
  ftp.close
81
- packages
78
+
79
+ download_ftp_list(uri, dirs)
82
80
  when "ssh"
83
81
  packages = []
84
82
  Net::SSH.start(uri.host, uri.user) do |ssh|
@@ -97,7 +95,38 @@ module Fig
97
95
  exit 10
98
96
  end
99
97
  end
100
-
98
+
99
+ def download_ftp_list(uri, dirs)
100
+ # Run a bunch of these in parallel since they're slow as hell
101
+ num_threads = 16
102
+ threads = []
103
+ all_packages = []
104
+ (0..num_threads-1).each { |num| all_packages[num] = [] }
105
+ (0..num_threads-1).each do |num|
106
+ threads << Thread.new do
107
+ packages = all_packages[num]
108
+ ftp = Net::FTP.new(uri.host)
109
+ ftp_login(ftp)
110
+ ftp.chdir(uri.path)
111
+ pos = num
112
+ while pos < dirs.length
113
+ pkg = dirs[pos]
114
+ begin
115
+ ftp.nlst(dirs[pos]).each do |ver|
116
+ packages << pkg + '/' + ver
117
+ end
118
+ rescue => e
119
+ packages << pkg + ' (' + e + ')'
120
+ end
121
+ pos += num_threads
122
+ end
123
+ ftp.close
124
+ end
125
+ end
126
+ threads.each { |thread| thread.join }
127
+ all_packages.flatten.sort
128
+ end
129
+
101
130
  def download(url, path)
102
131
  FileUtils.mkdir_p(File.dirname(path))
103
132
  uri = URI.parse(url)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Foemmel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2011-05-25 00:00:00 -05:00
12
+ date: 2011-05-26 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency