diff --git a/app/jobs/import_url_job.rb b/app/jobs/import_url_job.rb index cf779dcba7..c920d11522 100644 --- a/app/jobs/import_url_job.rb +++ b/app/jobs/import_url_job.rb @@ -62,7 +62,7 @@ def can_retrieve?(uri) # @param uri [URI] the uri of the file to download # @yield [IO] the stream to write to def copy_remote_file(uri, headers = {}) - filename = File.basename(uri.path) + filename = file_set.label dir = Dir.mktmpdir Rails.logger.debug("ImportUrlJob: Copying <#{uri}> to #{dir}") diff --git a/spec/jobs/import_url_job_spec.rb b/spec/jobs/import_url_job_spec.rb index 6cbced6f90..b25d353cd8 100644 --- a/spec/jobs/import_url_job_spec.rb +++ b/spec/jobs/import_url_job_spec.rb @@ -3,10 +3,11 @@ let(:file_path) { fixture_path + '/world.png' } let(:file_hash) { '/673467823498723948237462429793840923582' } + let(:file_name) { 'world.png' } let(:file_set) do FileSet.new(import_url: "http://example.org#{file_hash}", - label: file_path) do |f| + label: file_name) do |f| f.apply_depositor_metadata(user.user_key) end end @@ -74,7 +75,7 @@ it 'leaves the temp directory in place' do described_class.perform_now(file_set, operation) - expect(File.exist?(File.join(tmpdir, file_hash))).to be true + expect(File.exist?(File.join(tmpdir, file_name))).to be true end end