Skip to content

Commit

Permalink
more debug for importUrlJob
Browse files Browse the repository at this point in the history
  • Loading branch information
cziaarm committed Jul 23, 2024
1 parent 85add3d commit eb480e0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config/initializers/import_url_job_overrides.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
ImportUrlJob.class_eval do

def copy_remote_file(uri, name, headers = {})
filename = File.basename(name)
dir = Dir.mktmpdir
Rails.logger.debug("ImportUrlJob: Copying <#{uri}> to #{dir}")

File.open(File.join(dir, filename), 'wb') do |f|
begin
write_file(uri, f, headers)
yield f
rescue StandardError => e
STDERR.puts("IMPORT URL ERROR: #{e}")
send_error(e.message)
end
end
Rails.logger.debug("ImportUrlJob: Closing #{File.join(dir, filename)}")
end

def send_error(error_message)
user = User.find_by_user_key(file_set.depositor)
@file_set.errors.add('Error:', error_message)
Expand Down

0 comments on commit eb480e0

Please sign in to comment.