forked from e621ng/e621ng
[Cleanup] Don't return strategy on download
This commit is contained in:
parent
aa8e1037bf
commit
3aa731c408
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user