uploads: remove "this post was probably already uploaded" dupe check.

Also makes it so that using the bookmarklet always triggers async upload
preprocessing. Before it was only triggered when the source passed a
dupe check, but that check was inaccurate (#3873).
This commit is contained in:
evazion
2018-09-06 14:45:42 -05:00
parent 06cf32160b
commit 07c0695ac1
5 changed files with 7 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ class UploadsController < ApplicationController
def new def new
@upload_notice_wiki = WikiPage.titled(Danbooru.config.upload_notice_wiki_page).first @upload_notice_wiki = WikiPage.titled(Danbooru.config.upload_notice_wiki_page).first
@upload, @post, @source, @remote_size = UploadService::ControllerHelper.prepare( @upload, @remote_size = UploadService::ControllerHelper.prepare(
url: params[:url], ref: params[:ref] url: params[:url], ref: params[:ref]
) )
respond_with(@upload) respond_with(@upload)
@@ -43,7 +43,7 @@ class UploadsController < ApplicationController
end end
def preprocess def preprocess
@upload, @post, @source, @remote_size = UploadService::ControllerHelper.prepare( @upload, @remote_size = UploadService::ControllerHelper.prepare(
url: upload_params[:source], file: upload_params[:file], ref: upload_params[:referer_url] url: upload_params[:source], file: upload_params[:file], ref: upload_params[:referer_url]
) )
render body: nil render body: nil

View File

@@ -4,14 +4,8 @@ class UploadService
upload = Upload.new upload = Upload.new
if Utils.is_downloadable?(url) && file.nil? if Utils.is_downloadable?(url) && file.nil?
strategy = Sources::Strategies.find(url, ref) # this gets called from UploadsController#new so we need to preprocess async
post = Post.where("SourcePattern(lower(posts.source)) IN (?)", [url, strategy.canonical_url]).first Preprocessor.new(source: url, referer_url: ref).delay(priority: -1, queue: "default").delayed_start(CurrentUser.id)
if post.nil?
# this gets called from UploadsController#new so we need
# to preprocess async
Preprocessor.new(source: url, referer_url: ref).delay(priority: -1, queue: "default").delayed_start(CurrentUser.id)
end
begin begin
download = Downloads::File.new(url, ref) download = Downloads::File.new(url, ref)
@@ -19,7 +13,7 @@ class UploadService
rescue Exception rescue Exception
end end
return [upload, post, strategy, remote_size] return [upload, remote_size]
end end
if file if file

View File

@@ -1,5 +1,3 @@
<%# source %>
<div id="source-info"> <div id="source-info">
<p><%= link_to "Fetch source data", source_path(:format => "json"), :id => "fetch-data-manual" %></p> <p><%= link_to "Fetch source data", source_path(:format => "json"), :id => "fetch-data-manual" %></p>
<p><%= content_tag "span", "Loading source data...", :id => "loading-data", :style => "display: none;" %></p> <p><%= content_tag "span", "Loading source data...", :id => "loading-data", :style => "display: none;" %></p>

View File

@@ -1,6 +0,0 @@
<%# post %>
<% if post %>
<h2 style="margin-bottom: 1em;">
This post was probably already uploaded (<%= link_to "post ##{post.id}", post_path(post), :target => "_blank" %>)
</h2>
<% end %>

View File

@@ -12,8 +12,7 @@
<% end %> <% end %>
<%= render "image" %> <%= render "image" %>
<%= render "post", :post => @post %> <%= render "sources/info" %>
<%= render "sources/info", :source => @source %>
<div id="client-errors" class="error-messages ui-state-error ui-corner-all" style="display:none"></div> <div id="client-errors" class="error-messages ui-state-error ui-corner-all" style="display:none"></div>