From 6dd64da9ba6afa9d3602e07cc07b74ba821d0bf5 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Thu, 13 Sep 2018 13:50:18 -0700 Subject: [PATCH] fix invalid content type leaving upload stuck in preprocessing status (#3896) --- app/logical/upload_service/preprocessor.rb | 2 +- test/models/upload_service_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/logical/upload_service/preprocessor.rb b/app/logical/upload_service/preprocessor.rb index b1ebaab49..a42e5d0cf 100644 --- a/app/logical/upload_service/preprocessor.rb +++ b/app/logical/upload_service/preprocessor.rb @@ -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 diff --git a/test/models/upload_service_test.rb b/test/models/upload_service_test.rb index bcf05a509..395984d3a 100644 --- a/test/models/upload_service_test.rb +++ b/test/models/upload_service_test.rb @@ -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