cocoapods-meitu-bin 3.0.4 → 3.0.5

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: 4e9741581a964ad1099bc12fd3efc0c8ae28f6a1079b83de5c1dce623c9e6d07
4
- data.tar.gz: 129d2de33fb4b16f7a1bcdb0fe06ce330048911b42d53e7b1513fc92a46bc0d3
3
+ metadata.gz: 2688394e42a0c6c374a5151f87fdda88d99c006688892cc81a2f093200826849
4
+ data.tar.gz: 77130f1e064912c174d081a9384b7420239edabd27631bea4b76b532ee820897
5
5
  SHA512:
6
- metadata.gz: ad81790b9c2beaa7563d94405ade6931c2b38eabc5f2576bd2b4a5e0be6fefb3b5d839cf38aac6dc1d5fd674a17ab619ef053d7747b491507dbabde982dbde15
7
- data.tar.gz: 0d28b3a52bbab9cd14833ad8696b3fcc6e5a12d097a211bd09fe0a4e1845f72c55fb8fde1f7d9277df1bf2fc0d70f57e1cde7b02e160add804837a8545b0b075
6
+ metadata.gz: 06c4658c6146d0c00fb3e55bd34f01802c2d7618788e78e554b5ad1830eacc0a84446e8168134f80d44aeadb98fe41a3695287482c5a0f9a7d30f041c0229e41
7
+ data.tar.gz: 0ef886c0a3a9c3332cbb1a664db2b5c7c1044ae869729b221124011bf4813684f57ff77226abe37d1fb29f25e023e5efa9c737c97040eb814cc50e1b8e9c9aa6
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
4
4
 
5
5
  module Pod
@@ -6,9 +6,26 @@ module CBin
6
6
  # 多线程锁
7
7
  @@lock = Mutex.new
8
8
  # 阈值,单位MB
9
- @@size_threshold = 500
9
+ @@size_threshold = 300
10
10
  # 存放过大Pod信息的临时文件
11
11
  @@tmp_file_path = File.join(Dir.pwd, '.mtxx_big_pods.log')
12
+ # 存放实际下载压缩包大小的哈希,键为 target_path.to_s
13
+ @@archive_sizes = {}
14
+ @@archive_lock = Mutex.new
15
+
16
+ # 记录压缩包实际大小
17
+ def self.record_archive_size(target_path, size_kb)
18
+ @@archive_lock.synchronize do
19
+ @@archive_sizes[target_path.to_s] = size_kb
20
+ end
21
+ end
22
+
23
+ # 获取并移除对应 target_path 的压缩包大小
24
+ def self.get_archive_size(target_path)
25
+ @@archive_lock.synchronize do
26
+ @@archive_sizes.delete(target_path.to_s)
27
+ end
28
+ end
12
29
 
13
30
  # 添加超过阈值的pod
14
31
  def self.add_pod(pod)
@@ -8,6 +8,7 @@ require 'net/http'
8
8
  require 'cocoapods-meitu-bin/native/pod_source_installer'
9
9
  require 'cocoapods-meitu-bin/helpers/pod_size_helper'
10
10
  require 'cocoapods-meitu-bin/config/config'
11
+ require 'cocoapods-downloader/remote_file'
11
12
 
12
13
  module Pod
13
14
  class Installer
@@ -379,7 +380,8 @@ module Pod
379
380
 
380
381
  # 记录下载大小大于阈值的库及大小
381
382
  if File.exist?(target.to_s)
382
- dir_size = `du -sk #{target.to_s}`.strip().split(' ')[0]
383
+ archive_size = CBin::PodSize.get_archive_size(target)
384
+ dir_size = archive_size ? archive_size : `du -sk #{target.to_s}`.strip().split(' ')[0]
383
385
  CBin::PodSize.add_pod({:name => request.name, :size => dir_size})
384
386
  end
385
387
 
@@ -398,3 +400,18 @@ module Pod
398
400
  end
399
401
  end
400
402
  end
403
+
404
+ module Pod
405
+ module Downloader
406
+ class RemoteFile
407
+ alias mtxx_extract_with_type extract_with_type
408
+ def extract_with_type(full_filename, type = :zip)
409
+ if File.exist?(full_filename)
410
+ size_kb = File.size(full_filename) / 1024
411
+ CBin::PodSize.record_archive_size(target_path, size_kb)
412
+ end
413
+ mtxx_extract_with_type(full_filename, type)
414
+ end
415
+ end
416
+ end
417
+ end
@@ -7,6 +7,21 @@ module Pod
7
7
  VALID_EXTNAME = %w[.binary.podspec.json .binary.podspec .podspec.json .podspec].freeze
8
8
  DEFAULT_TEMPLATE_EXTNAME = %w[.binary-template.podspec .binary-template.podspec.json].freeze
9
9
 
10
+ alias old_checksum checksum
11
+ def checksum
12
+ if defined_in_file && !File.exist?(defined_in_file)
13
+ begin
14
+ defined_in_file.dirname.mkpath
15
+ content = respond_to?(:to_pretty_json) ? to_pretty_json : (respond_to?(:to_json) ? to_json : to_yaml)
16
+ defined_in_file.open('w') { |f| f << content }
17
+ rescue => e
18
+ content = respond_to?(:to_pretty_json) ? to_pretty_json : (respond_to?(:to_json) ? to_json : to_yaml)
19
+ return Digest::SHA1.hexdigest(content)
20
+ end
21
+ end
22
+ old_checksum
23
+ end
24
+
10
25
  # TODO
11
26
  # 可以在这里根据组件依赖二进制或源码调整 sources 的先后顺序
12
27
  # 如果是源码,则调整 code_source 到最前面
@@ -10,3 +10,31 @@ module Pod
10
10
  end
11
11
  end
12
12
 
13
+ module CBin
14
+ describe PodSize do
15
+ it 'records and gets archive size correctly' do
16
+ PodSize.record_archive_size('/path/to/target', 12345)
17
+ PodSize.get_archive_size('/path/to/target').should == 12345
18
+ # Once retrieved, it should be deleted
19
+ PodSize.get_archive_size('/path/to/target').should.be.nil
20
+ end
21
+ end
22
+ end
23
+
24
+ module Pod
25
+ describe Downloader::RemoteFile do
26
+ it 'records size when extracting' do
27
+ downloader = Downloader::RemoteFile.new('/tmp/dummy_target', 'http://dummy.com/file.zip', {})
28
+
29
+ File.stubs(:exist?).with('/tmp/dummy_target/file.zip').returns(true)
30
+ File.stubs(:size).with('/tmp/dummy_target/file.zip').returns(102400)
31
+
32
+ downloader.stubs(:mtxx_extract_with_type).returns(nil)
33
+ downloader.extract_with_type('/tmp/dummy_target/file.zip', :zip)
34
+
35
+ CBin::PodSize.get_archive_size('/tmp/dummy_target').should == 100
36
+ end
37
+ end
38
+ end
39
+
40
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-meitu-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-29 00:00:00.000000000 Z
11
+ date: 2026-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel