[Cleanup] Don't return strategy on download

This commit is contained in:
Earlopain 2022-03-16 17:15:45 +01:00
parent aa8e1037bf
commit 3aa731c408
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
5 changed files with 6 additions and 9 deletions

View File

@ -28,8 +28,7 @@ module Downloads
def download!(tries: 3, **options)
Retriable.retriable(on: RETRIABLE_ERRORS, tries: tries, base_interval: 0) do
file = http_get_streaming(uncached_url, headers: strategy.headers, **options)
return [file, strategy]
http_get_streaming(uncached_url, headers: strategy.headers, **options)
end
end

View File

@ -146,9 +146,7 @@ class UploadService
raise RuntimeError, "No file or source URL provided" if upload.direct_url_parsed.blank?
download = Downloads::File.new(upload.direct_url_parsed, upload.referer_url)
file, strategy = download.download!
return file
download.download!
end
end
end

View File

@ -103,7 +103,7 @@ class PostReplacement < ApplicationRecord
end
download = Downloads::File.new(replacement_url_parsed, "")
file, strategy = download.download!
file = download.download!
self.replacement_file = file
self.source = "#{self.source}\n" + replacement_url

View File

@ -37,7 +37,7 @@ class UploadServiceTest < ActiveSupport::TestCase
@mock_upload.stubs(:direct_url_parsed).returns(@source)
@mock_upload.stubs(:referer_url).returns(nil)
@bad_file = File.open("#{Rails.root}/test/files/test-corrupt.jpg", "rb")
Downloads::File.any_instance.stubs(:download!).returns([@bad_file, nil])
Downloads::File.any_instance.stubs(:download!).returns(@bad_file)
end
teardown do

View File

@ -49,7 +49,7 @@ module Downloads
HTTParty.expects(:get).twice.multiple_yields("a", bomb, "b", "c").then.multiple_yields("a", "b", "c").returns(resp)
@download.stubs(:is_cloudflare?).returns(false)
tempfile, _ = @download.download!
tempfile = @download.download!
assert_equal("abc", tempfile.read)
end
@ -62,7 +62,7 @@ module Downloads
end
should "store the file in the tempfile path" do
tempfile, strategy = @download.download!
tempfile = @download.download!
assert_operator(tempfile.size, :>, 0, "should have data")
end
end