puushload 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/puushload.rb +3 -7
- metadata +1 -1
data/lib/puushload.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
gem "archive-tar-minitar", "~> 0.5.2"
|
4
|
-
|
5
3
|
require 'puushload/puush_downloader'
|
6
4
|
require 'puushload/puush_helper'
|
7
5
|
require 'puushload/puush_id_generator'
|
@@ -12,7 +10,7 @@ require 'logger'
|
|
12
10
|
require 'tmpdir'
|
13
11
|
|
14
12
|
class PuushLoad
|
15
|
-
MAX_THREADS =
|
13
|
+
MAX_THREADS = 20
|
16
14
|
ARCHIVE_SIZE = 1000
|
17
15
|
|
18
16
|
def initialize(outputFolder, logger)
|
@@ -33,12 +31,10 @@ class PuushLoad
|
|
33
31
|
FileUtils.mkdir_p(@output_folder)
|
34
32
|
|
35
33
|
PuushIDGenerator.generate do |id|
|
36
|
-
|
37
34
|
spawned_threads << Thread.new {
|
38
|
-
PuushDownloader.download_file(id, current_tmp_dir, @logger)
|
39
|
-
downloaded_files += 1
|
35
|
+
downloaded_files += 1 if PuushDownloader.download_file(id, current_tmp_dir, @logger)
|
40
36
|
}
|
41
|
-
|
37
|
+
sleep 0.01
|
42
38
|
if spawned_threads.length >= MAX_THREADS
|
43
39
|
spawned_threads.each { |spawnedThread| spawnedThread.join }
|
44
40
|
spawned_threads.clear
|