mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
DEV: Update uploads:list_posts_with_broken_images
to recover from tombstone.
This commit is contained in:
parent
d4080c020f
commit
4a966c639d
@ -43,10 +43,10 @@ class S3Helper
|
||||
rescue Aws::S3::Errors::NoSuchKey
|
||||
end
|
||||
|
||||
def copy(source, destination)
|
||||
def copy(source, destination, options: {})
|
||||
s3_bucket
|
||||
.object(destination)
|
||||
.copy_from(copy_source: File.join(@s3_bucket_name, source))
|
||||
.copy_from(options.merge(copy_source: File.join(@s3_bucket_name, source)))
|
||||
end
|
||||
|
||||
# make sure we have a cors config for assets
|
||||
|
@ -772,6 +772,16 @@ end
|
||||
def recover_from_s3_by_sha1(post:, sha1:, object_keys: [])
|
||||
object_keys.each do |key|
|
||||
if key =~ /#{sha1}/
|
||||
tombstone_prefix = FileStore::S3Store::TOMBSTONE_PREFIX
|
||||
|
||||
if key.starts_with?(tombstone_prefix)
|
||||
Discourse.store.s3_helper.copy(
|
||||
key,
|
||||
key.sub(tombstone_prefix, ""),
|
||||
options: { acl: "public-read" }
|
||||
)
|
||||
end
|
||||
|
||||
url = "https:#{SiteSetting.Upload.absolute_base_url}/#{key}"
|
||||
|
||||
begin
|
||||
@ -790,7 +800,7 @@ def recover_from_s3_by_sha1(post:, sha1:, object_keys: [])
|
||||
if upload.persisted?
|
||||
post.rebake!
|
||||
else
|
||||
puts "#{post.full_url}\n#{upload.errors.full_messages.join("\n")}"
|
||||
puts "#{post.full_url}: #{upload.errors.full_messages.join(", ")}"
|
||||
end
|
||||
end
|
||||
ensure
|
||||
|
Loading…
Reference in New Issue
Block a user