uploads: fixup bug in 2d47ae70b causing disk uploads to fail.

Fix a nil dereference error when uploading files from disk.
This commit is contained in:
evazion
2022-02-01 13:53:52 -06:00
parent 38ebda7415
commit 317d369c6a

View File

@@ -38,7 +38,7 @@ class UploadsController < ApplicationController
def show
@upload = authorize Upload.find(params[:id])
@post = Post.new(uploader: @upload.uploader, uploader_ip_addr: @upload.uploader_ip_addr, source: @upload.source, rating: nil, **permitted_attributes(Post))
@post.tag_string = "#{@post.tag_string} #{@upload.source_strategy.artists.map(&:tag).map(&:name).join(" ")}".strip
@post.tag_string = "#{@post.tag_string} #{@upload.source_strategy&.artists.to_a.map(&:tag).map(&:name).join(" ")}".strip
if request.format.html? && @upload.is_completed? && @upload.media_assets.first&.post.present?
flash[:notice] = "Duplicate of post ##{@upload.media_assets.first.post.id}"