lib/selenium/webdriver/common/zipper.rb in selenium-webdriver-0.1.3 vs lib/selenium/webdriver/common/zipper.rb in selenium-webdriver-0.1.4
- old
+ new
@@ -25,11 +25,13 @@
destination
end
def self.zip(path)
# can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
- Dir.mktmpdir { |tmp_dir|
+ # 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-zip")
Zip::ZipFile.open(zip_path, Zip::ZipFile::CREATE) { |zip|
::Find.find(path) do |file|
next if File.directory?(file)
@@ -38,10 +40,12 @@
zip.add entry, file
end
}
File.open(zip_path, "rb") { |io| Base64.encode64 io.read }
- }
+ ensure
+ FileUtils.rm_rf tmp_dir
+ end
end
end # Zipper
end # WebDriver
end # Selenium