jpsclient 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfae70995f49f8f2aa2a5217a432e8df567375d05b9c4740f90cd023f393c907
4
- data.tar.gz: 76da513a3884f1d33ba66b739cb9a43cdb03b899386f31c084b68d487a8888d9
3
+ metadata.gz: 3ef98823dc402c55c62119942c2e90475b5934e566b86fb885ad5fd2ef407b17
4
+ data.tar.gz: f27e02b694c5f8b69a66c8deb003a82bd35d0060c1fa32297f59e006886368d6
5
5
  SHA512:
6
- metadata.gz: 19b1f3cb1b678e44d2472c5a0c5dc12ce2d45b207e2c964d633d2ebe1a7640c9c48c757bcb4bad2fbd1d26029247e7fbd9714b54081951559c1f556afbf1fa50
7
- data.tar.gz: b79d3962ca2d54943f96dc983b5ee20401a9a7d9cfa9cc64692c3727123603e16e934019d7f37b076ccaa2c79b2fbd52eeed6c10cc80633cb66aeebcb691b93e
6
+ metadata.gz: 1ca3f48d61ea772ef9db667bffc4f37609c6e7539b6d4573c20974d7617daae79a982f7e7dd4c21f883d9185848fa6fc7919a0aa048b050304ad67b3c2279f31
7
+ data.tar.gz: 4cbf794f6bfac6d8c684ef38d0b200f3889935f52c0ddde1b457afe99b8a95459bd937d38c7d9bc577d279dd87b0852e9a9fa1f881279601288280c6ded7b76a
@@ -123,6 +123,8 @@ module JPSClient
123
123
  return upload_result
124
124
  end
125
125
 
126
+ # 进度条已经在上传过程中自动更新到100%,不需要再手动设置
127
+
126
128
  # 步骤3: 完成多部分上传
127
129
  Logger.instance.fancyinfo_start("完成上传...")
128
130
  complete_result = @jps_client.complete_file_multipart(
@@ -312,6 +314,10 @@ module JPSClient
312
314
  # 处理响应结果
313
315
  if response.success?
314
316
  @progress_bar.complete_upload_index(upload_part:part_no, complete_size:read_length)
317
+ # 只有在未完成时才更新进度条,避免100%时重复显示
318
+ unless @progress_bar.is_done
319
+ @progress_bar.update_upload_progress()
320
+ end
315
321
  # 新API不再需要收集ETag,只记录成功的分片号
316
322
  @upload_eTags_mutex.synchronize { @upload_eTags << part_no }
317
323
  else
@@ -44,9 +44,10 @@ module JPSClient
44
44
  end
45
45
  end
46
46
 
47
- def update_upload_progress()
47
+ def update_upload_progress(force_update: false)
48
48
  time_now = (Time.now.to_f * 1000).to_i #毫秒
49
- if time_now - @last_update_time > 80
49
+ # 允许强制更新或者满足时间间隔条件
50
+ if force_update || time_now - @last_update_time > 80
50
51
  @mutex.synchronize do
51
52
  @last_update_time = time_now
52
53
  total_num = @upload_total_size
@@ -55,15 +56,20 @@ module JPSClient
55
56
  index_num = index_num + value
56
57
  end
57
58
 
59
+ # 确保不会超过100%
60
+ index_num = [index_num, total_num].min
61
+
58
62
  progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
59
63
  total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 )
60
64
  upload_size = sprintf("%.2f", 1.00 * index_num / 1024 /1024 )
61
65
  index = 40.0 * index_num / total_num
62
66
  upload_message = "已上传:#{upload_size}MB|#{progress_str}\%【" + (@draw_char * (index/1).floor).ljust(40.0, '_') + "】Total:#{total_size}MB"
63
- Logger.instance.fancyinfo_update(upload_message)
64
- if index_num == total_num && !@is_done
67
+
68
+ if index_num >= total_num && !@is_done
65
69
  @is_done = true
66
- Logger.instance.fancyinfo_success(upload_message)
70
+ Logger.instance.fancyinfo_complete(upload_message)
71
+ else
72
+ Logger.instance.fancyinfo_update(upload_message)
67
73
  end
68
74
  end
69
75
  end
@@ -27,6 +27,12 @@ module JPSClient
27
27
  $stdout.flush
28
28
  end
29
29
 
30
+ def fancyinfo_complete(message)
31
+ # 完成时先清除当前行,然后打印完成信息
32
+ print "\r" + " " * 100 + "\r" # 清除当前行
33
+ puts "✅ #{message}"
34
+ end
35
+
30
36
  def info(message)
31
37
  puts message if @verbose
32
38
  end
@@ -1,3 +1,3 @@
1
1
  module JPSClient
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpsclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-22 00:00:00.000000000 Z
10
+ date: 2025-09-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday