pindo 4.8.0 → 4.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26a76bb1d95b970919b4b386f52841ddc4cb21ac22a7b5d433c7fcc88b6030da
4
- data.tar.gz: e0f0eb7ec08a2fca3489b0d469fe23eaa0f34ea9d88bcb209b50df822f42e406
3
+ metadata.gz: 0cff4bb49b837340114cc7cb33a2a6d2cbbb91ac74e97a2485d803887fdc2713
4
+ data.tar.gz: 8b4390944c7a344643014534b9167f01ace020bf4fac8ff3ac485da4c4ae7506
5
5
  SHA512:
6
- metadata.gz: 9d95421e56c75ed51b5d75b7e84aa2e7dba6c566379d6cc23e3966aa616dc15f0c433552b5963c04ae36f488891dc80b1f2ac8b79f0069d166daaaf59c942bd0
7
- data.tar.gz: a3c6c60f5398b336f17a79bff657a4eb0b28882328828fc05507bbe38a03e4785f455492dffd0800df788d686351ecc3376a88e8e69bd3e2268337417571f2f6
6
+ metadata.gz: 8dbc329c5d290c7abbcf75dee882a07ea7187187ba38287271fa485c21d75fd22fcd8267a362d38e49e4bb87813ab6b0d56c53c67dae1e49f570de0ad6c68739
7
+ data.tar.gz: 2263c2090f3377f75241d8b9a0adfb8db568acce03393f01eae36e0413ca1303cd4cde8ba6c5ebb2b70c9d4b2b47d28095e18516e7d236e262a8a6bf38e6f52f
@@ -99,7 +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"
102
+ puts
103
+ puts "切片大小: 5MB"
103
104
 
104
105
  upload_result = nil
105
106
 
@@ -108,7 +109,8 @@ module Pindo
108
109
 
109
110
  upload_id= result_data["data"]["uploadId"]
110
111
  @upload_params_list = result_data["data"]["uploadParamsList"]
111
- task_num = @upload_params_list.length
112
+ task_num = @upload_params_list.length
113
+ retry_count = 5
112
114
  if task_num < 2
113
115
  task_num = 2
114
116
  end
@@ -116,8 +118,9 @@ module Pindo
116
118
  if task_num > 100
117
119
  task_num = 100
118
120
  end
119
-
120
- puts "最大线程数: #{task_num}"
121
+
122
+ puts "线程个数: #{task_num}"
123
+ puts "重试次数: #{retry_count}"
121
124
  puts
122
125
 
123
126
  Funlog.instance.fancyinfo_start("开始上传...")
@@ -126,7 +129,7 @@ module Pindo
126
129
  # single_task_upload_data_req( )
127
130
 
128
131
 
129
- multi_task_upload_data_req(task_num:task_num)
132
+ multi_task_upload_data_req(task_num:task_num, retry_count:retry_count)
130
133
 
131
134
  result_data = post_upload_finish_req(upload_path_key:upload_path_key, upload_id:upload_id, eTags:@upload_eTags)
132
135
 
@@ -143,11 +146,10 @@ module Pindo
143
146
  end
144
147
 
145
148
 
146
- def multi_task_upload_data_req(task_num:1)
147
-
149
+ def multi_task_upload_data_req(task_num:1, retry_count: 3)
148
150
 
149
151
  for i in 0..@upload_params_list.length-1 do
150
- @upload_params_list[i]["retryCount"] = 3
152
+ @upload_params_list[i]["retryCount"] = retry_count
151
153
  end
152
154
 
153
155
  while @upload_params_list.size > 0
@@ -201,7 +203,6 @@ module Pindo
201
203
  put_data = file.read(read_length)
202
204
 
203
205
  request = create_req(upload_url:upload_url, body_data:put_data, read_length:read_length)
204
-
205
206
  request.on_progress do |dltotal, dlnow, ultotal, ulnow|
206
207
  if ulnow
207
208
  @progress_bar.update_upload_index(upload_part:part_no, upload_size:ulnow)
@@ -209,8 +210,6 @@ module Pindo
209
210
  end
210
211
  end
211
212
 
212
- eTag_item = nil
213
-
214
213
  request.on_complete do |response|
215
214
  if response.success?
216
215
  @progress_bar.complete_upload_index(upload_part:part_no, complete_size:read_length)
@@ -221,7 +220,8 @@ module Pindo
221
220
  @progress_bar.delete_upload_index(upload_part:part_no)
222
221
  upload_params_item["retryCount"] = upload_params_item["retryCount"] - 1
223
222
  if upload_params_item["retryCount"] > 0
224
- @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)
225
225
  else
226
226
  Funlog.instance.fancyinfo_error("文件#{@upload_binary_file} 上传失败! 😭😭😭")
227
227
  raise Informative, "上传文件失败"
@@ -234,9 +234,6 @@ module Pindo
234
234
  else
235
235
  hydra_handle.queue(request)
236
236
  end
237
-
238
- return eTag_item
239
-
240
237
  end
241
238
 
242
239
  def create_req(upload_url:nil, body_data:nil, read_length:nil)
@@ -341,6 +338,7 @@ module Pindo
341
338
  attr_accessor :upload_total_size
342
339
  attr_accessor :last_update_time
343
340
  attr_accessor :update_ing_size
341
+ attr_accessor :is_done
344
342
 
345
343
  def initialize(upload_total_size:nil, draw_char:'>')
346
344
 
@@ -351,6 +349,8 @@ module Pindo
351
349
 
352
350
  @complete_size = 0
353
351
  @update_ing_size = {}
352
+
353
+ @is_done = false
354
354
  end
355
355
 
356
356
  def update_upload_index(upload_part:nil, upload_size:nil)
@@ -373,7 +373,7 @@ module Pindo
373
373
  total_num = @upload_total_size
374
374
  index_num = @complete_size
375
375
  @update_ing_size.each do |key, value|
376
- index_num = index_num + value
376
+ index_num = index_num + value
377
377
  end
378
378
 
379
379
  progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
@@ -382,19 +382,14 @@ module Pindo
382
382
  index = 40.0 * index_num / total_num
383
383
  upload_message = "已上传:#{upload_size}MB|#{progress_str}\%【" + (@draw_char * (index/1).floor).ljust(40.0, '_') + "】Total:#{total_size}MB"
384
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
385
389
  end
386
390
  end
387
391
 
388
392
  end
389
393
 
390
- # def set_progress(index_num, total_num, char ='>' )
391
- # progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
392
- # total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 )
393
- # upload_size = sprintf("%.2f", 1.00 * index_num / 1024 /1024 )
394
- # index = 40.0 * index_num / total_num
395
- # upload_message = "已上传:#{upload_size}MB|#{progress_str}\%【" + (char * (index/1).floor).ljust(40.0, '_') + "】Total:#{total_size}MB"
396
- # Funlog.instance.fancyinfo_update(upload_message)
397
- # end
398
-
399
394
  end
400
395
  end
data/lib/pindo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pindo
2
2
 
3
- VERSION = "4.8.0"
3
+ VERSION = "4.8.1"
4
4
 
5
5
  class VersionCheck
6
6
 
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.8.0
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-24 00:00:00.000000000 Z
11
+ date: 2024-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide