mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-16 17:05:09 -04:00
Merge pull request #4432 from tgxworld/migrate_upload_scheme_to_scheduled_job
FIX: Make `Jobs::MigrateUploadScheme` a scheduled job.
This commit is contained in:
commit
0fbb949af5
1 changed files with 6 additions and 4 deletions
|
@ -1,8 +1,10 @@
|
|||
module Jobs
|
||||
|
||||
class MigrateUploadScheme < Jobs::Onceoff
|
||||
class MigrateUploadScheme < Jobs::Scheduled
|
||||
every 10.minutes
|
||||
sidekiq_options retry: false
|
||||
|
||||
def execute_onceoff(args)
|
||||
def execute(args)
|
||||
return unless SiteSetting.migrate_to_new_scheme
|
||||
|
||||
# clean up failed uploads
|
||||
|
@ -11,7 +13,7 @@ module Jobs
|
|||
.destroy_all
|
||||
|
||||
# migrate uploads to new scheme
|
||||
problems = Upload.migrate_to_new_scheme
|
||||
problems = Upload.migrate_to_new_scheme(50)
|
||||
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))
|
||||
|
@ -23,7 +25,7 @@ module Jobs
|
|||
OptimizedImage.where("upload_id NOT IN (SELECT id FROM uploads)").destroy_all
|
||||
|
||||
# migrate optimized_images to new scheme
|
||||
problems = OptimizedImage.migrate_to_new_scheme
|
||||
problems = OptimizedImage.migrate_to_new_scheme(50)
|
||||
problems.each do |hash|
|
||||
optimized_image_id = hash[:optimized_image].id
|
||||
Discourse.handle_job_exception(hash[:ex], error_context(args, "Migrating optimized_image id #{optimized_image_id}", optimized_image_id: optimized_image_id))
|
||||
|
|
Loading…
Add table
Reference in a new issue