lib/chromedriver_update.rb in chromedriver_update-0.1.9 vs lib/chromedriver_update.rb in chromedriver_update-0.2.0
- old
+ new
@@ -17,10 +17,11 @@
# Update the installed version of chromedriver automatically fitting to the currently installed version of chrome
#
def self.auto_update_chromedriver(force: false)
if installed_chrome_version.split(".").first != installed_chromedriver_version.split(".").first || force
original_chromedriver_version = installed_chromedriver_version
+ original_chromedriver_path = chromedriver_path
chromedriver_zip = HTTParty.get(chromedriver_link_for_version(installed_chrome_version))
if chromedriver_zip.code == 404 # fallback to latest lower version
chromedriver_zip = HTTParty.get(chromedriver_closest_link_for_version(installed_chrome_version))
end
destination_dir = File.expand_path(File.dirname(__FILE__) + "/../tmp")
@@ -30,16 +31,21 @@
if (entry.name.end_with?("/chromedriver") || entry.name.end_with?("/chromedriver.exe"))
download_path = File.join(destination_dir, File.basename(entry.name))
FileUtils.rm_f(download_path)
entry.extract(download_path)
FileUtils.mv(download_path, chromedriver_path, force: true)
- begin
- FileUtils.chmod("+x", chromedriver_path)
- rescue
- unless OS.windows?
+ unless OS.windows?
+ begin
+ FileUtils.chmod("+x", original_chromedriver_path)
+ `chmod +x "#{original_chromedriver_path}"`
+ rescue
begin
- `sudo chmod +x "#{chromedriver_path}"`
+ `chmod +x "#{original_chromedriver_path}"`
rescue
+ begin
+ `sudo chmod +x "#{original_chromedriver_path}"`
+ rescue
+ end
end
end
end
end
end