Class: Pod::Downloader::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-mtxx-bin/native/installer.rb

Constant Summary collapse

@@lock =

多线程锁

Mutex.new

Instance Method Summary collapse

Instance Method Details

#ensure_matching_versionObject



196
197
198
199
200
201
202
203
204
205
206
# File 'lib/cocoapods-mtxx-bin/native/installer.rb', line 196

def ensure_matching_version
  @@lock.synchronize do
    version_file = root + 'VERSION'
    # version = version_file.read.strip if version_file.file?

    # root.rmtree if version != Pod::VERSION && root.exist?
    root.mkpath

    version_file.open('w') { |f| f << Pod::VERSION }
  end
end

#old_ensure_matching_versionObject

rmtree 在多进程情况下可能 Directory not empty @ dir_s_rmdir 错误 old_ensure_matching_version 会移除不是同一个 CocoaPods 版本的组件缓存



195
# File 'lib/cocoapods-mtxx-bin/native/installer.rb', line 195

alias old_ensure_matching_version ensure_matching_version

#uncached_pod(request) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/cocoapods-mtxx-bin/native/installer.rb', line 208

def uncached_pod(request)
  in_tmpdir do |target|
    result, podspecs = download(request, target)
    result.location = nil

    # 记录下载大小大于阈值的库及大小
    if File.exist?(target.to_s)
      dir_size = `du -sk #{target.to_s}`.strip().split(' ')[0]
      CBin::PodSize.add_pod({:name => request.name, :size => dir_size})
    end

    podspecs.each do |name, spec|
      destination = path_for_pod(request, :name => name, :params => result.checkout_options)
      copy_and_clean(target, destination, spec)
      write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
      if request.name == name
        result.location = destination
      end
    end

    result
  end
end