Merge pull request #3875 from evazion/fix-3873
Fix #3873: Batch bookmarklet for tumblr reports wrong posts as already uploaded
This commit is contained in:
@@ -179,6 +179,18 @@ module Sources
|
||||
return {}
|
||||
end
|
||||
|
||||
# A search query that should return any posts that were previously
|
||||
# uploaded from the same source. These may be duplicates, or they may be
|
||||
# other posts from the same gallery.
|
||||
def related_posts_search_query
|
||||
"source:#{canonical_url}"
|
||||
end
|
||||
|
||||
def related_posts(limit = 5)
|
||||
CurrentUser.as_system { Post.tag_match(related_posts_search_query).paginate(1, limit: limit) }
|
||||
end
|
||||
memoize :related_posts
|
||||
|
||||
def to_h
|
||||
return {
|
||||
:artist_name => artist_name,
|
||||
|
||||
@@ -153,6 +153,10 @@ module Sources
|
||||
translated_tags
|
||||
end
|
||||
|
||||
def related_posts_search_query
|
||||
illust_id.present? ? "pixiv:#{illust_id}" : "source:#{canonical_url}"
|
||||
end
|
||||
|
||||
public
|
||||
|
||||
def image_urls_sub
|
||||
|
||||
@@ -4,14 +4,8 @@ class UploadService
|
||||
upload = Upload.new
|
||||
|
||||
if Utils.is_downloadable?(url) && file.nil?
|
||||
strategy = Sources::Strategies.find(url, ref)
|
||||
post = Post.where("SourcePattern(lower(posts.source)) IN (?)", [url, strategy.canonical_url]).first
|
||||
|
||||
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
|
||||
# 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)
|
||||
|
||||
begin
|
||||
download = Downloads::File.new(url, ref)
|
||||
@@ -19,7 +13,7 @@ class UploadService
|
||||
rescue Exception
|
||||
end
|
||||
|
||||
return [upload, post, strategy, remote_size]
|
||||
return [upload, remote_size]
|
||||
end
|
||||
|
||||
if file
|
||||
@@ -29,11 +23,5 @@ class UploadService
|
||||
|
||||
return [upload]
|
||||
end
|
||||
|
||||
def self.batch(url, ref = nil)
|
||||
if url
|
||||
return Sources::Strategies.find(url, ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user