Class: Pod::Downloader::Cache

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

Constant Summary collapse

@@lock =

多线程锁

Mutex.new

Instance Method Summary collapse

Instance Method Details

#ensure_matching_versionObject



231
232
233
234
235
236
237
238
239
240
241
# File 'lib/cocoapods-meitu-bin/native/installer.rb', line 231

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 版本的组件缓存



230
# File 'lib/cocoapods-meitu-bin/native/installer.rb', line 230

alias old_ensure_matching_version ensure_matching_version

#uncached_pod(request) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/cocoapods-meitu-bin/native/installer.rb', line 243

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