Skip to content

Commit

Permalink
Merge pull request #561 from NREL/zip_issue
Browse files Browse the repository at this point in the history
fix unzip issue
  • Loading branch information
brianlball authored May 16, 2020
2 parents 82e25f7 + 181e229 commit bd1d99f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem 'colored'
# data modules
gem 'jbuilder'
gem 'nokogiri', '~> 1.8.2'
gem 'rubyzip', '~> 1.2'
gem 'rubyzip', '~> 1.3.0'
gem 'tzinfo-data'

# database modules
Expand Down Expand Up @@ -114,7 +114,7 @@ group :development, :test do
gem 'rspec-rails'
gem 'rspec-retry'
gem 'ruby-prof', '~> 0.15'
gem 'selenium-webdriver', '3.141.0'
gem 'selenium-webdriver'

gem 'psych', '~> 3.1.0'
gem 'rubocop', '0.64.0'
Expand Down
10 changes: 5 additions & 5 deletions server/app/jobs/dj_jobs/run_simulate_data_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ def logger
# This is local function for workaround until that is resolved
#OpenStudio::Workflow.extract_archive(download_file, analysis_dir)
def extract_archive(archive_filename, destination, overwrite = true)
::Zip.sort_entries = true
Zip::File.open(archive_filename) do |zf|
zf.each do |f|
@sim_logger.info "Zip: Extracting #{f.name}"
f_path = File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))

if File.exist?(f_path) && overwrite
FileUtils.rm_rf(f_path)
zf.extract(f, f_path)
elsif !File.exist? f_path
if File.exist?(f_path)
@sim_logger.warn "SKIPPED: #{f.name}, already existed."
else
zf.extract(f, f_path)
end
end
Expand Down
10 changes: 5 additions & 5 deletions server/app/models/analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ def shared_directory_path
# This is local function for workaround until that is resolved
#OpenStudio::Workflow.extract_archive(download_file, analysis_dir)
def extract_archive(archive_filename, destination, overwrite = true)
::Zip.sort_entries = true
Zip::File.open(archive_filename) do |zf|
zf.each do |f|
logger.info "Extracting #{f.name}"
f_path = File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))

if File.exist?(f_path) && overwrite
FileUtils.rm_rf(f_path)
zf.extract(f, f_path)
elsif !File.exist? f_path
if File.exist?(f_path)
logger.info "SKIPPED: #{f.name}, already existed."
else
zf.extract(f, f_path)
end
end
Expand Down

0 comments on commit bd1d99f

Please sign in to comment.