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



309
310
311
312
313
314
315
316
317
318
319
# File 'lib/cocoapods-meitu-bin/native/installer.rb', line 309

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



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

alias old_ensure_matching_version ensure_matching_version

#uncached_pod(request) ⇒ Object



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/cocoapods-meitu-bin/native/installer.rb', line 321

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