-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix miss cache file problem on Jenkins concurrent install. #6535
Conversation
@yanzhiwei147 at first glance this seems okay. Any thoughts on how we can test this? |
Sorry, I try to add some test case for this issue.but unsuccessful. |
It can be run normal on Jenkins concurrent install now for me. |
lib/cocoapods/downloader/cache.rb
Outdated
lock_file_path = lock_path_for_pod(request, :name => name, :params => result.checkout_options) | ||
|
||
File.new(lock_file_path, File::CREAT) unless File.exist? lock_file_path | ||
File.open(lock_file_path) { |file| file.flock(File::LOCK_EX) && copy_and_clean(target, destination, spec) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yanzhiwei147 shouldn't we unlock the file once we are done?
Something akin to:
success = file.flock(mode)
if success
begin
yield file
ensure
file.flock(File::LOCK_UN)
end
Taken from https://www.safaribooksonline.com/library/view/ruby-cookbook/0596523696/ch06s13.html
lib/cocoapods/downloader/cache.rb
Outdated
@@ -107,6 +107,20 @@ def path_for_pod(request, slug_opts = {}) | |||
# the download options that should be used in constructing the | |||
# cache slug for this request. | |||
# | |||
# @return [string] The lock file path for the Pod downloaded from the given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: [String]
(capital 'S')
lib/cocoapods/downloader/cache.rb
Outdated
@@ -156,7 +170,16 @@ def uncached_pod(request) | |||
|
|||
podspecs.each do |name, spec| | |||
destination = path_for_pod(request, :name => name, :params => result.checkout_options) | |||
copy_and_clean(target, destination, spec) | |||
|
|||
# add file lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"add file lock" does not add any context to any other programmer who reads this as to why a file lock is being used here. If the code is simple and self explanatory then I suggest removing this comment entirely, otherwise please expand it to explain why the lock is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lib/cocoapods/downloader/cache.rb
Outdated
# @param [mode] mode | ||
# the file lock mode. | ||
# | ||
# @return [boolean] The result of lock specific file and mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Boolean]
lib/cocoapods/downloader/cache.rb
Outdated
@@ -167,6 +190,26 @@ def uncached_pod(request) | |||
end | |||
end | |||
|
|||
# @param [file] file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[File]
👍 from me. |
I would be really hesitant to merge this - we'd still be a long way from correctly supporting concurrent |
@dnkoutso It can be merged? |
@yanzhiwei147 rebase it please? |
Closing due to inactivity. |
Fix miss cache file problem on Jenkins concurrent install