Permalink
Browse files

Don't try to clean up temp directories and files that may still be in…

… use
  • Loading branch information...
mbklein committed Feb 13, 2018
1 parent 0a4ac8b commit 1ebe664073c71b12d3908ab14fa8e73786c79e54
Showing with 9 additions and 8 deletions.
  1. +9 −8 app/jobs/import_url_job.rb
@@ -49,15 +49,16 @@ def perform(file_set, operation)
# @yield [IO] the stream to write to
def copy_remote_file(uri)
filename = File.basename(uri.path)
Dir.mktmpdir do |dir|
File.open(File.join(dir, filename), 'wb') do |f|
retriever = BrowseEverything::Retriever.new
retriever.retrieve('url' => uri) do |chunk|
f.write(chunk)
end
f.rewind
yield f
dir = Dir.mktmpdir
Rails.logger.debug("ImportUrlJob: Copying <#{uri}> to #{dir}")
File.open(File.join(dir, filename), 'wb') do |f|
retriever = BrowseEverything::Retriever.new
retriever.retrieve('url' => uri) do |chunk|
f.write(chunk)
end
f.rewind
yield f
end
Rails.logger.debug("ImportUrlJob: Closing #{File.join(dir, filename)}")
end
end

0 comments on commit 1ebe664

Please sign in to comment.