uploads: consider uploads as failed when all assets fail.

Make the "completed" status for an upload mean "at least one file in the
upload successfully completed". The "error" status means "all files in
the upload failed".

This means that when an upload has multiple assets and some succeed and
some fail, the whole upload is considered completed. This can happen
when uploading multiple files and some files are over the size limit,
for example. The upload is considered failed only if all files in the
upload fail.

This fixes an issue where, if uploading a single file and that file
failed because it was over the size limit, then the upload wouldn't be
marked as failed.
This commit is contained in:
evazion
2022-02-15 16:53:43 -06:00
parent b6538fde38
commit 16b8d4b607
3 changed files with 13 additions and 11 deletions

View File

@@ -211,9 +211,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
context "for a video longer than the video length limit" do
should "fail for a regular user" do
@source = "https://cdn.donmai.us/original/63/cb/63cb09f2526ef3ac14f11c011516ad9b.webm"
post_auth uploads_path(format: :json), @user, params: { upload: { source: @source }}
perform_enqueued_jobs
create_upload!("https://cdn.donmai.us/original/63/cb/63cb09f2526ef3ac14f11c011516ad9b.webm", user: @user)
assert_response 201
assert_match("Duration must be less than", Upload.last.error)