bd_pod_cache_lock 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bd_pod_cache_lock.rb +60 -73
- data/lib/bd_pod_cache_lock/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6629c951a4631ea0570c53146e1dfc572676c404fa811d6315a69dab046e92a9
|
4
|
+
data.tar.gz: a2e8752abf48edc1e51d2843ea8e682f459aa1e9f39586b5e5f871728def4326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d0ccf81d22bad9d97472676730b7fc6a6e9fc3eaabfa48847d82b8b447e2481d71794fdd969d2b44651e19d821f1a3c93f0b3723759ea7e95737c301f72f715
|
7
|
+
data.tar.gz: 07d8e56b92cd3040240450e239d7676b06ce6c1cc21348b5f353c4a866d7c69dfe05031b6be1ceadd90431cd84a295c1fac39fb6ac8c2afa3ee49ab821f83925
|
data/Gemfile.lock
CHANGED
data/lib/bd_pod_cache_lock.rb
CHANGED
@@ -4,93 +4,80 @@ require 'tmpdir'
|
|
4
4
|
require 'digest/sha1'
|
5
5
|
|
6
6
|
ROOT_PROCESS_ID = Process.pid
|
7
|
+
$locked = false
|
7
8
|
|
8
|
-
$
|
9
|
+
$pod_cache_dir = Pod::Config.instance.cache_root + 'Pods'
|
10
|
+
$pod_cache_lock_dir = $pod_cache_dir + 'CacheLock'
|
11
|
+
$pod_install_lock_file = $pod_cache_dir + 'pod_install.lock'
|
9
12
|
|
10
13
|
at_exit do
|
11
|
-
if(Process.pid == ROOT_PROCESS_ID)
|
12
|
-
FileUtils.rm_rf($
|
13
|
-
puts "
|
14
|
+
if(Process.pid == ROOT_PROCESS_ID && $locked)
|
15
|
+
FileUtils.rm_rf($pod_install_lock_file)
|
16
|
+
puts "UnLock Pod install"
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
module Pod
|
18
|
-
|
19
|
-
#
|
20
|
-
# them in a cache directory.
|
21
|
+
class Installer
|
22
|
+
# Installs the Pods.
|
21
23
|
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Dir.mkdir($pod_cache_lock_dir) unless Dir.exist?($pod_cache_lock_dir)
|
37
|
-
request_sha1 = Digest::SHA1.hexdigest(request.slug(slug_opts))
|
38
|
-
return ($pod_cache_lock_dir + request_sha1).to_s + '.lock'
|
39
|
-
end
|
40
|
-
|
41
|
-
# @param [Request] request
|
42
|
-
# the request to be downloaded.
|
43
|
-
#
|
44
|
-
# @return [Response] The download response for the given `request` that
|
45
|
-
# was not found in the download cache.
|
46
|
-
#
|
47
|
-
def uncached_pod(request)
|
48
|
-
in_tmpdir do |target|
|
49
|
-
result, podspecs = download(request, target)
|
50
|
-
result.location = nil
|
51
|
-
|
52
|
-
podspecs.each do |name, spec|
|
53
|
-
destination = path_for_pod(request, :name => name, :params => result.checkout_options)
|
54
|
-
|
55
|
-
destination.parent.mkpath
|
56
|
-
lock_file_path = lock_path_for_pod(request, :name => name, :params => result.checkout_options)
|
57
|
-
|
58
|
-
puts lock_file_path
|
59
|
-
File.new(lock_file_path, File::CREAT) unless File.exist? lock_file_path
|
60
|
-
File.open(lock_file_path) do |file|
|
61
|
-
flock(file, File::LOCK_EX) { copy_and_clean(target, destination, spec) }
|
62
|
-
end
|
24
|
+
# The installation process is mostly linear with a few minor complications
|
25
|
+
# to keep in mind:
|
26
|
+
#
|
27
|
+
# - The stored podspecs need to be cleaned before the resolution step
|
28
|
+
# otherwise the sandbox might return an old podspec and not download
|
29
|
+
# the new one from an external source.
|
30
|
+
# - The resolver might trigger the download of Pods from external sources
|
31
|
+
# necessary to retrieve their podspec (unless it is instructed not to
|
32
|
+
# do it).
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
#
|
36
|
+
def install!
|
37
|
+
Dir.mkdir($pod_cache_dir) unless Dir.exist?($pod_cache_dir)
|
63
38
|
|
64
|
-
|
65
|
-
if request.name == name
|
66
|
-
result.location = destination
|
67
|
-
end
|
68
|
-
end
|
39
|
+
lock_file_path = $pod_install_lock_file
|
69
40
|
|
70
|
-
|
71
|
-
|
41
|
+
File.new(lock_file_path, File::CREAT) unless File.exist? lock_file_path
|
42
|
+
File.open(lock_file_path) do |file|
|
43
|
+
flock(file, File::LOCK_EX) {
|
44
|
+
puts "Lock Pod install"
|
45
|
+
$locked = true
|
46
|
+
prepare
|
47
|
+
resolve_dependencies
|
48
|
+
download_dependencies
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
validate_targets
|
53
|
+
generate_pods_project
|
54
|
+
if installation_options.integrate_targets?
|
55
|
+
integrate_user_project
|
56
|
+
else
|
57
|
+
UI.section 'Skipping User Project Integration'
|
72
58
|
end
|
59
|
+
perform_post_install_actions
|
60
|
+
end
|
73
61
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
62
|
+
# @param [File] file
|
63
|
+
# should be locked file.
|
64
|
+
#
|
65
|
+
# @param [mode] mode
|
66
|
+
# the file lock mode.
|
67
|
+
#
|
68
|
+
# @return [Boolean] The result of lock specific file and mode.
|
69
|
+
#
|
70
|
+
def flock(file, mode)
|
71
|
+
success = file.flock(mode)
|
72
|
+
if success
|
73
|
+
begin
|
74
|
+
yield file
|
75
|
+
ensure
|
76
|
+
file.flock(File::LOCK_UN)
|
90
77
|
end
|
91
|
-
success
|
92
78
|
end
|
93
|
-
|
79
|
+
success
|
94
80
|
end
|
95
81
|
end
|
96
82
|
end
|
83
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bd_pod_cache_lock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- liuyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|