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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39f06457454a7e8cf5a0a07b8af301b3cdd199ead72a469ae7464397226cf166
4
- data.tar.gz: 5f7e6c150730e4956a2dc7d530a8259b7e0392ed415963091c0da04a40f4bc44
3
+ metadata.gz: 6629c951a4631ea0570c53146e1dfc572676c404fa811d6315a69dab046e92a9
4
+ data.tar.gz: a2e8752abf48edc1e51d2843ea8e682f459aa1e9f39586b5e5f871728def4326
5
5
  SHA512:
6
- metadata.gz: 3d6eb03c5b46f7fc772d550f3397044bf180de8f436e26b17172fa81bd04b696b2c5469acfe371a84b8182605f82f32715fd3d04bd92dfeda9d7d617ebb332fa
7
- data.tar.gz: 630d515b7ccc9c7f0cf671abc04f0ffccae1eb5c71391a6073f634484e032b6dc1cb86e325eb9ed876fc67a8e03e11327fef4c4752160b9d464969ca3e25d865
6
+ metadata.gz: 1d0ccf81d22bad9d97472676730b7fc6a6e9fc3eaabfa48847d82b8b447e2481d71794fdd969d2b44651e19d821f1a3c93f0b3723759ea7e95737c301f72f715
7
+ data.tar.gz: 07d8e56b92cd3040240450e239d7676b06ce6c1cc21348b5f353c4a866d7c69dfe05031b6be1ceadd90431cd84a295c1fac39fb6ac8c2afa3ee49ab821f83925
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bd_pod_cache_lock (1.0.0)
4
+ bd_pod_cache_lock (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- $pod_cache_lock_dir = Pod::Config.instance.cache_root + 'Pods' + 'CacheLock'
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($pod_cache_lock_dir)
13
- puts "Unlocked"
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
- module Downloader
19
- # The class responsible for managing Pod downloads, transparently caching
20
- # them in a cache directory.
21
+ class Installer
22
+ # Installs the Pods.
21
23
  #
22
- class Cache
23
-
24
- # @param [Request] request
25
- # the request to be downloaded.
26
- #
27
- # @param [Hash<Symbol,String>] slug_opts
28
- # the download options that should be used in constructing the
29
- # cache slug for this request.
30
- #
31
- # @return [String] The lock file path for the Pod downloaded from the given
32
- # `request`.
33
- #
34
- def lock_path_for_pod(request, slug_opts = {})
35
- lock_dir = root + "CacheLock"
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
- write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
65
- if request.name == name
66
- result.location = destination
67
- end
68
- end
39
+ lock_file_path = $pod_install_lock_file
69
40
 
70
- result
71
- end
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
- # @param [File] file
75
- # should be locked file.
76
- #
77
- # @param [mode] mode
78
- # the file lock mode.
79
- #
80
- # @return [Boolean] The result of lock specific file and mode.
81
- #
82
- def flock(file, mode)
83
- success = file.flock(mode)
84
- if success
85
- begin
86
- yield file
87
- ensure
88
- file.flock(File::LOCK_UN)
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
+
@@ -1,3 +1,3 @@
1
1
  module BdPodCacheLock
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
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.1
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: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2019-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler