Skip to content

Commit

Permalink
CocoaPods/CocoaPods#11827, Fix Concurrent building occasionally clean…
Browse files Browse the repository at this point in the history
…s the Pods cache directory
  • Loading branch information
chengcong committed Apr 10, 2023
1 parent 5cb2450 commit 5df4576
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cocoapods-fix-cache.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cocoapods-fix-cache/gem_version.rb'
require 'cocoapods-fix-cache.rb'

Gem::Specification.new do |spec|
spec.name = 'cocoapods-fix-cache'
Expand Down
4 changes: 3 additions & 1 deletion lib/cocoapods-fix-cache.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require 'cocoapods-fix-cache/gem_version'
module CocoapodsFixCache
VERSION = "0.1.0"
end
1 change: 0 additions & 1 deletion lib/cocoapods-fix-cache/command.rb

This file was deleted.

44 changes: 0 additions & 44 deletions lib/cocoapods-fix-cache/command/cache.rb

This file was deleted.

23 changes: 23 additions & 0 deletions lib/cocoapods-fix-cache/fix-cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Pod
module Downloader
class Cache
alias_method :old_ensure_matching_version, :ensure_matching_version
def ensure_matching_version
# Fix Concurrent building occasionally cleans the Pods cache directory #11826 #11827
# https://github.com/CocoaPods/CocoaPods/pull/11827
if Cache.respond_to?(:read_lock) && Cache.respond_to?(:write_lock)
version_file = root + "VERSION"
version = nil
Cache.read_lock(version_file) { version = version_file.read.strip if version_file.file? }

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

Cache.write_lock(version_file) { version_file.open("w") { |f| f << Pod::VERSION } }
else
old_ensure_matching_version
end
end
end
end
end
3 changes: 0 additions & 3 deletions lib/cocoapods-fix-cache/gem_version.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/cocoapods_plugin.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'cocoapods-fix-cache/command'
require "cocoapods-fix-cache/fix-cache"

0 comments on commit 5df4576

Please sign in to comment.