diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 0b8d42ae8ef9c6d11e7af844e09173f58011a2ad..28b6f538d0078f9df10cd699b849ea137f2da613 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -25,14 +25,18 @@ module Gitlab File.exists? path end - # Locks the satellite and yields + # * Locks the satellite + # * Changes the current directory to the satellite's working dir + # * Yields def lock raise "Satellite doesn't exist" unless exists? File.open(lock_file, "w+") do |f| f.flock(File::LOCK_EX) - return yield + Dir.chdir(path) do + return yield + end end end