diff --git a/lib/file_store/to_s3_migration.rb b/lib/file_store/to_s3_migration.rb index 01c69dc1ee9..6792b94e4ae 100644 --- a/lib/file_store/to_s3_migration.rb +++ b/lib/file_store/to_s3_migration.rb @@ -6,6 +6,8 @@ module FileStore ToS3MigrationError = Class.new(RuntimeError) class ToS3Migration + MISSING_UPLOADS_RAKE_TASK_NAME ||= 'posts:missing_uploads' + def initialize(s3_options:, dry_run: false, migrate_to_multisite: false, skip_etag_verify: false) @s3_bucket = s3_options[:bucket] @@ -85,8 +87,8 @@ module FileStore success = false end - Discourse::Application.load_tasks - Rake::Task['posts:missing_uploads'] + Discourse::Application.load_tasks unless Rake::Task.task_defined?(MISSING_UPLOADS_RAKE_TASK_NAME) + Rake::Task[MISSING_UPLOADS_RAKE_TASK_NAME] count = DB.query_single(<<~SQL, Post::MISSING_UPLOADS, Post::MISSING_UPLOADS_IGNORED).first SELECT COUNT(1) FROM posts p