pindo 4.7.9 → 4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pindo/client/pgyeruploadclient.rb +27 -24
- data/lib/pindo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cff4bb49b837340114cc7cb33a2a6d2cbbb91ac74e97a2485d803887fdc2713
|
4
|
+
data.tar.gz: 8b4390944c7a344643014534b9167f01ace020bf4fac8ff3ac485da4c4ae7506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dbc329c5d290c7abbcf75dee882a07ea7187187ba38287271fa485c21d75fd22fcd8267a362d38e49e4bb87813ab6b0d56c53c67dae1e49f570de0ad6c68739
|
7
|
+
data.tar.gz: 2263c2090f3377f75241d8b9a0adfb8db568acce03393f01eae36e0413ca1303cd4cde8ba6c5ebb2b70c9d4b2b47d28095e18516e7d236e262a8a6bf38e6f52f
|
@@ -99,9 +99,8 @@ module Pindo
|
|
99
99
|
puts "文件路径: #{@upload_binary_file}"
|
100
100
|
puts "文件大小: #{total_m}M"
|
101
101
|
puts "上传路径: #{upload_path_key}"
|
102
|
-
puts "切片大小: 5 MB"
|
103
|
-
puts "最大线程数: #{task_num}"
|
104
102
|
puts
|
103
|
+
puts "切片大小: 5MB"
|
105
104
|
|
106
105
|
upload_result = nil
|
107
106
|
|
@@ -110,7 +109,19 @@ module Pindo
|
|
110
109
|
|
111
110
|
upload_id= result_data["data"]["uploadId"]
|
112
111
|
@upload_params_list = result_data["data"]["uploadParamsList"]
|
112
|
+
task_num = @upload_params_list.length
|
113
|
+
retry_count = 5
|
114
|
+
if task_num < 2
|
115
|
+
task_num = 2
|
116
|
+
end
|
117
|
+
|
118
|
+
if task_num > 100
|
119
|
+
task_num = 100
|
120
|
+
end
|
113
121
|
|
122
|
+
puts "线程个数: #{task_num}"
|
123
|
+
puts "重试次数: #{retry_count}"
|
124
|
+
puts
|
114
125
|
|
115
126
|
Funlog.instance.fancyinfo_start("开始上传...")
|
116
127
|
@upload_eTags = []
|
@@ -118,10 +129,10 @@ module Pindo
|
|
118
129
|
# single_task_upload_data_req( )
|
119
130
|
|
120
131
|
|
121
|
-
multi_task_upload_data_req(task_num:task_num)
|
132
|
+
multi_task_upload_data_req(task_num:task_num, retry_count:retry_count)
|
122
133
|
|
123
134
|
result_data = post_upload_finish_req(upload_path_key:upload_path_key, upload_id:upload_id, eTags:@upload_eTags)
|
124
|
-
|
135
|
+
|
125
136
|
if result_data["code"] == 200
|
126
137
|
upload_result = upload_path_key
|
127
138
|
Funlog.instance.fancyinfo_success("文件#{@upload_binary_file} 上传成功! 😎😎😎")
|
@@ -135,11 +146,10 @@ module Pindo
|
|
135
146
|
end
|
136
147
|
|
137
148
|
|
138
|
-
def multi_task_upload_data_req(task_num:1)
|
139
|
-
|
149
|
+
def multi_task_upload_data_req(task_num:1, retry_count: 3)
|
140
150
|
|
141
151
|
for i in 0..@upload_params_list.length-1 do
|
142
|
-
@upload_params_list[i]["retryCount"] =
|
152
|
+
@upload_params_list[i]["retryCount"] = retry_count
|
143
153
|
end
|
144
154
|
|
145
155
|
while @upload_params_list.size > 0
|
@@ -193,7 +203,6 @@ module Pindo
|
|
193
203
|
put_data = file.read(read_length)
|
194
204
|
|
195
205
|
request = create_req(upload_url:upload_url, body_data:put_data, read_length:read_length)
|
196
|
-
|
197
206
|
request.on_progress do |dltotal, dlnow, ultotal, ulnow|
|
198
207
|
if ulnow
|
199
208
|
@progress_bar.update_upload_index(upload_part:part_no, upload_size:ulnow)
|
@@ -201,8 +210,6 @@ module Pindo
|
|
201
210
|
end
|
202
211
|
end
|
203
212
|
|
204
|
-
eTag_item = nil
|
205
|
-
|
206
213
|
request.on_complete do |response|
|
207
214
|
if response.success?
|
208
215
|
@progress_bar.complete_upload_index(upload_part:part_no, complete_size:read_length)
|
@@ -213,7 +220,8 @@ module Pindo
|
|
213
220
|
@progress_bar.delete_upload_index(upload_part:part_no)
|
214
221
|
upload_params_item["retryCount"] = upload_params_item["retryCount"] - 1
|
215
222
|
if upload_params_item["retryCount"] > 0
|
216
|
-
@upload_params_list.push(upload_params_item)
|
223
|
+
# @upload_params_list.push(upload_params_item)
|
224
|
+
single_task_upload_part_data_req(upload_params_item:upload_params_item, hydra_handle:hydra_handle)
|
217
225
|
else
|
218
226
|
Funlog.instance.fancyinfo_error("文件#{@upload_binary_file} 上传失败! 😭😭😭")
|
219
227
|
raise Informative, "上传文件失败"
|
@@ -226,9 +234,6 @@ module Pindo
|
|
226
234
|
else
|
227
235
|
hydra_handle.queue(request)
|
228
236
|
end
|
229
|
-
|
230
|
-
return eTag_item
|
231
|
-
|
232
237
|
end
|
233
238
|
|
234
239
|
def create_req(upload_url:nil, body_data:nil, read_length:nil)
|
@@ -333,6 +338,7 @@ module Pindo
|
|
333
338
|
attr_accessor :upload_total_size
|
334
339
|
attr_accessor :last_update_time
|
335
340
|
attr_accessor :update_ing_size
|
341
|
+
attr_accessor :is_done
|
336
342
|
|
337
343
|
def initialize(upload_total_size:nil, draw_char:'>')
|
338
344
|
|
@@ -343,6 +349,8 @@ module Pindo
|
|
343
349
|
|
344
350
|
@complete_size = 0
|
345
351
|
@update_ing_size = {}
|
352
|
+
|
353
|
+
@is_done = false
|
346
354
|
end
|
347
355
|
|
348
356
|
def update_upload_index(upload_part:nil, upload_size:nil)
|
@@ -365,7 +373,7 @@ module Pindo
|
|
365
373
|
total_num = @upload_total_size
|
366
374
|
index_num = @complete_size
|
367
375
|
@update_ing_size.each do |key, value|
|
368
|
-
|
376
|
+
index_num = index_num + value
|
369
377
|
end
|
370
378
|
|
371
379
|
progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
|
@@ -374,19 +382,14 @@ module Pindo
|
|
374
382
|
index = 40.0 * index_num / total_num
|
375
383
|
upload_message = "已上传:#{upload_size}MB|#{progress_str}\%【" + (@draw_char * (index/1).floor).ljust(40.0, '_') + "】Total:#{total_size}MB"
|
376
384
|
Funlog.instance.fancyinfo_update(upload_message)
|
385
|
+
if index_num == total_num && !@is_done
|
386
|
+
@is_done = true
|
387
|
+
Funlog.instance.fancyinfo_success(upload_message)
|
388
|
+
end
|
377
389
|
end
|
378
390
|
end
|
379
391
|
|
380
392
|
end
|
381
393
|
|
382
|
-
# def set_progress(index_num, total_num, char ='>' )
|
383
|
-
# progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
|
384
|
-
# total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 )
|
385
|
-
# upload_size = sprintf("%.2f", 1.00 * index_num / 1024 /1024 )
|
386
|
-
# index = 40.0 * index_num / total_num
|
387
|
-
# upload_message = "已上传:#{upload_size}MB|#{progress_str}\%【" + (char * (index/1).floor).ljust(40.0, '_') + "】Total:#{total_size}MB"
|
388
|
-
# Funlog.instance.fancyinfo_update(upload_message)
|
389
|
-
# end
|
390
|
-
|
391
394
|
end
|
392
395
|
end
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pindo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|