mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: add post migration checks and raise error if failed.
This commit is contained in:
parent
0ddfeb9c64
commit
be3fb85a04
@ -348,9 +348,12 @@ def migrate_to_s3
|
||||
|
||||
puts
|
||||
|
||||
failure_message = "S3 migration failed for db '#{db}'."
|
||||
|
||||
if failed.size > 0
|
||||
puts "Failed to upload #{failed.size} files"
|
||||
puts failed.join("\n")
|
||||
raise failure_message
|
||||
elsif s3_objects.size + synced >= local_files.size
|
||||
puts "Updating the URLs in the database..."
|
||||
|
||||
@ -437,6 +440,18 @@ def migrate_to_s3
|
||||
end
|
||||
end
|
||||
|
||||
base_url = File.join(SiteSetting.Upload.s3_base_url, prefix)
|
||||
count = Upload.where("url NOT LIKE '#{base_url}%'").count
|
||||
raise "#{count} of #{Upload.count} uploads are not migrated to S3. #{failure_message}" if count > 0
|
||||
|
||||
cdn_path = SiteSetting.cdn_path("/uploads/#{db}").sub(/https?:/, "")
|
||||
count = Post.where("cooked LIKE '%#{cdn_path}%'").count
|
||||
raise "#{count} posts are not remapped to new S3 upload URL. #{failure_message}" if count > 0
|
||||
|
||||
Rake::Task['posts:missing_uploads'].invoke
|
||||
count = PostCustomField.where(name: Post::MISSING_UPLOADS).count
|
||||
raise failure_message if count > 0
|
||||
|
||||
puts "Done!"
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user