Skip to content

Commit

Permalink
Remove tempfile compatibility for Ruby 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Oct 13, 2021
1 parent 3a21814 commit a83f9be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
8 changes: 1 addition & 7 deletions rb/lib/selenium/webdriver/common/profile_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,10 @@ module ClassMethods
def from_json(json)
data = decoded(json)

# can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
# can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
tmp_dir = Dir.mktmpdir
begin
zip_path = File.join(tmp_dir, "webdriver-profile-duplicate-#{json.hash}.zip")
Tempfile.create do |zip_path|
File.open(zip_path, 'wb') { |zip_file| zip_file << Base64.decode64(data) }

new Zipper.unzip(zip_path)
ensure
FileUtils.rm_rf tmp_dir
end
end
end # ClassMethods
Expand Down
10 changes: 1 addition & 9 deletions rb/lib/selenium/webdriver/common/zipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,8 @@ def zip_file(path)
private

def with_tmp_zip(&blk)
# can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
# can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
tmp_dir = Dir.mktmpdir
zip_path = File.join(tmp_dir, 'webdriver-zip')

begin
Tempfile.create do |zip_path|
Zip::File.open(zip_path, Zip::File::CREATE, &blk)
ensure
FileUtils.rm_rf tmp_dir
FileUtils.rm_rf zip_path
end
end

Expand Down

0 comments on commit a83f9be

Please sign in to comment.