From baae0e7446baba8a1c74460999904ade57879797 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sun, 19 Apr 2020 20:21:58 +0200 Subject: [PATCH] FIX: Infinite loop in migrate_to_s3 rake task --- lib/file_store/to_s3_migration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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