From 2e346e6ea28616366a443c82f097a2c0b82135c4 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 24 Apr 2019 14:32:39 +1000 Subject: [PATCH] FEATURE: stop running migrate to new scheme once done This setting will automatically disable itself when there are no longer any problem uploads --- app/jobs/scheduled/migrate_upload_scheme.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/jobs/scheduled/migrate_upload_scheme.rb b/app/jobs/scheduled/migrate_upload_scheme.rb index 5516c710452..84e1013eaf3 100644 --- a/app/jobs/scheduled/migrate_upload_scheme.rb +++ b/app/jobs/scheduled/migrate_upload_scheme.rb @@ -5,7 +5,7 @@ module Jobs sidekiq_options retry: false def execute(args) - return unless SiteSetting.migrate_to_new_scheme + return if !SiteSetting.migrate_to_new_scheme # clean up failed uploads Upload.where("created_at < ?", 1.hour.ago) @@ -18,6 +18,11 @@ module Jobs # migrate uploads to new scheme problems = Upload.migrate_to_new_scheme(limit: 50) + if problems.length == 0 + # This job is no longer needed skip it from now + SiteSetting.migrate_to_new_scheme = false + end + problems.each do |hash| upload_id = hash[:upload].id Discourse.handle_job_exception(hash[:ex], error_context(args, "Migrating upload id #{upload_id}", upload_id: upload_id))