lib/command/executor/fetcher.rb in cocoapods-binary-artifactory-cache-0.0.12 vs lib/command/executor/fetcher.rb in cocoapods-binary-artifactory-cache-0.0.13

- old
+ new

@@ -8,10 +8,11 @@ @resolved_targets = [] def initialize(options) super(options) @repo_update = options[:repo_update] + @unpack_mutex = Mutex.new end def run Pod::UI.step("Fetching cache") do FileUtils.mkdir_p(@config.prebuild_sandbox_path) @@ -41,11 +42,11 @@ unless to_dir.nil? FileUtils.mkdir_p(to_dir) end end cache_paths = @resolved_targets.map {|target| "/#{target.name}/#{target.version}.zip"} - Parallel.each(cache_paths, in_threads: 8) do |path| + Parallel.each(cache_paths, in_threads: 4) do |path| cache_path = @config.generated_frameworks_dir(in_cache: true) + path if File.exists?(cache_path) == false || File.zero?(cache_path) == true File.open(cache_path, "wb") do |file| begin file.write open(repo + path, :http_basic_authentication => [@config.artifactory_login, @config.artifactory_password]).read @@ -78,12 +79,17 @@ @config.manifest_path(in_cache: true), @config.manifest_path ) end zip_paths = @resolved_targets.map {|target| @config.generated_frameworks_dir(in_cache: true) + "/#{target.name}/#{target.version}.zip"} - Parallel.each(zip_paths, in_threads: 8) do |path| + Parallel.each(zip_paths, in_threads: 4) do |path| if File.exists? path - ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir) + @unpack_mutex.synchronize do + unless ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir) + File.delete(path) + Pod::UI.puts "Remove bad archive #{path}".yellow + end + end end end end end end