From 26a6335c41f15f56ed0938cb2c94904de2d50149 Mon Sep 17 00:00:00 2001 From: nonamethanks Date: Mon, 14 Dec 2020 16:39:04 +0100 Subject: [PATCH] Uploads: get rid of same-source existence check Remove the lines that checked for existing upload with the same source. These lines were breaking replacements in many cases, so we had to always empty the post's source before replacing, and they served no purpose since the md5 check already catches duplicate uploads. --- app/logical/upload_service/preprocessor.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/logical/upload_service/preprocessor.rb b/app/logical/upload_service/preprocessor.rb index e4148fd03..067cdba67 100644 --- a/app/logical/upload_service/preprocessor.rb +++ b/app/logical/upload_service/preprocessor.rb @@ -66,20 +66,6 @@ class UploadService def start! raise NotImplementedError, "No login credentials configured for #{strategy.site_name}." unless strategy.class.enabled? - if Utils.is_downloadable?(source) - if Post.system_tag_match("source:#{canonical_source}").where.not(id: original_post_id).exists? - raise ActiveRecord::RecordNotUnique, "A post with source #{canonical_source} already exists" - end - - if Upload.where(source: source, status: "completed").exists? - raise ActiveRecord::RecordNotUnique, "A completed upload with source #{source} already exists" - end - - if Upload.where(source: source).where("status like ?", "error%").exists? - raise ActiveRecord::RecordNotUnique, "An errored upload with source #{source} already exists" - end - end - params[:rating] ||= "q" params[:tag_string] ||= "tagme" upload = Upload.create!(params)