Revert "DEV: Remove unused kwarg and properly check for local missing uploads."
This reverts commit 97769f3d02
.
The code is confusing but this change is quite risky. Defer for now
until we can look at it properly.
This commit is contained in:
parent
97769f3d02
commit
8a64b0c8e8
|
@ -885,7 +885,7 @@ class Post < ActiveRecord::Base
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_upload_url(fragments: nil, local_store: nil)
|
def each_upload_url(fragments: nil, include_local_upload: true)
|
||||||
current_db = RailsMultisite::ConnectionManagement.current_db
|
current_db = RailsMultisite::ConnectionManagement.current_db
|
||||||
upload_patterns = [
|
upload_patterns = [
|
||||||
/\/uploads\/#{current_db}\//,
|
/\/uploads\/#{current_db}\//,
|
||||||
|
@ -902,7 +902,7 @@ class Post < ActiveRecord::Base
|
||||||
next if Rails.configuration.multisite && src.exclude?(current_db) && src.exclude?("short-url")
|
next if Rails.configuration.multisite && src.exclude?(current_db) && src.exclude?("short-url")
|
||||||
|
|
||||||
src = "#{SiteSetting.force_https ? "https" : "http"}:#{src}" if src.start_with?("//")
|
src = "#{SiteSetting.force_https ? "https" : "http"}:#{src}" if src.start_with?("//")
|
||||||
next unless Discourse.store.has_been_uploaded?(src) || (local_store && local_store.has_been_uploaded?(src))
|
next unless Discourse.store.has_been_uploaded?(src) || (include_local_upload && src =~ /\A\/[^\/]/i)
|
||||||
|
|
||||||
path = begin
|
path = begin
|
||||||
URI(URI.unescape(src))&.path
|
URI(URI.unescape(src))&.path
|
||||||
|
@ -922,7 +922,7 @@ class Post < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_missing_uploads
|
def self.find_missing_uploads(include_local_upload: true)
|
||||||
missing_uploads = []
|
missing_uploads = []
|
||||||
missing_post_uploads = {}
|
missing_post_uploads = {}
|
||||||
count = 0
|
count = 0
|
||||||
|
|
|
@ -82,7 +82,7 @@ class S3Inventory
|
||||||
def list_missing_post_uploads
|
def list_missing_post_uploads
|
||||||
log "Listing missing post uploads..."
|
log "Listing missing post uploads..."
|
||||||
|
|
||||||
missing = Post.find_missing_uploads do |post, _, _, sha1|
|
missing = Post.find_missing_uploads(include_local_upload: false) do |post, _, _, sha1|
|
||||||
next if sha1.blank?
|
next if sha1.blank?
|
||||||
|
|
||||||
upload_id = nil
|
upload_id = nil
|
||||||
|
|
|
@ -413,7 +413,7 @@ def missing_uploads
|
||||||
|
|
||||||
count_missing = 0
|
count_missing = 0
|
||||||
|
|
||||||
missing = Post.find_missing_uploads(local_store: FileStore::LocalStore.new) do |post, src, path, sha1|
|
missing = Post.find_missing_uploads(include_local_upload: true) do |post, src, path, sha1|
|
||||||
next if sha1.present?
|
next if sha1.present?
|
||||||
puts "Fixing missing uploads: " if count_missing == 0
|
puts "Fixing missing uploads: " if count_missing == 0
|
||||||
count_missing += 1
|
count_missing += 1
|
||||||
|
|
Loading…
Reference in New Issue