Skip to content

Commit a83f9be

Browse files
committed
Remove tempfile compatibility for Ruby 1.8
1 parent 3a21814 commit a83f9be

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

rb/lib/selenium/webdriver/common/profile_helper.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,10 @@ module ClassMethods
7373
def from_json(json)
7474
data = decoded(json)
7575

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

8379
new Zipper.unzip(zip_path)
84-
ensure
85-
FileUtils.rm_rf tmp_dir
8680
end
8781
end
8882
end # ClassMethods

rb/lib/selenium/webdriver/common/zipper.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@ def zip_file(path)
7272
private
7373

7474
def with_tmp_zip(&blk)
75-
# can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
76-
# can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
77-
tmp_dir = Dir.mktmpdir
78-
zip_path = File.join(tmp_dir, 'webdriver-zip')
79-
80-
begin
75+
Tempfile.create do |zip_path|
8176
Zip::File.open(zip_path, Zip::File::CREATE, &blk)
82-
ensure
83-
FileUtils.rm_rf tmp_dir
84-
FileUtils.rm_rf zip_path
8577
end
8678
end
8779

0 commit comments

Comments
 (0)