fix invalid content type leaving upload stuck in preprocessing status (#3896)

This commit is contained in:
Albert Yi
2018-09-13 13:50:18 -07:00
parent 4b75ccf89f
commit 6dd64da9ba
2 changed files with 13 additions and 1 deletions

View File

@@ -104,7 +104,7 @@ class UploadService
upload.status = "preprocessed"
upload.save!
rescue Exception => x
upload.update(status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n"))
upload.update(file_ext: nil, status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n"))
end
return upload

View File

@@ -489,6 +489,18 @@ class UploadServiceTest < ActiveSupport::TestCase
end
end
context "for an invalid content type" do
setup do
@source = "http://www.example.com"
@service = subject.new(source: @source)
end
should "fail" do
upload = @service.start!
upload.reload
assert_match(/error:/, upload.status)
end
end
end
context "#finish!" do