ensure course_copy_worker runs on local shard
closes #CNVS-21273 Change-Id: I3513e08cd63647a402f54bb0c77f7e090d17e279 Reviewed-on: https://gerrit.instructure.com/56659 Tested-by: Jenkins Reviewed-by: Dan Minkevitch <dan@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
98f1f75bb3
commit
8436ddc8de
|
@ -26,56 +26,58 @@ class Canvas::Migration::Worker::CourseCopyWorker < Struct.new(:migration_id)
|
|||
cm.save
|
||||
cm.job_progress.start
|
||||
|
||||
begin
|
||||
source = cm.source_course || Course.find(cm.migration_settings[:source_course_id])
|
||||
ce = ContentExport.new
|
||||
ce.context = source
|
||||
ce.content_migration = cm
|
||||
ce.selected_content = cm.copy_options
|
||||
ce.export_type = ContentExport::COURSE_COPY
|
||||
ce.user = cm.user
|
||||
ce.save!
|
||||
cm.content_export = ce
|
||||
cm.shard.activate do
|
||||
begin
|
||||
source = cm.source_course || Course.find(cm.migration_settings[:source_course_id])
|
||||
ce = ContentExport.new
|
||||
ce.context = source
|
||||
ce.content_migration = cm
|
||||
ce.selected_content = cm.copy_options
|
||||
ce.export_type = ContentExport::COURSE_COPY
|
||||
ce.user = cm.user
|
||||
ce.save!
|
||||
cm.content_export = ce
|
||||
|
||||
ce.export_without_send_later
|
||||
ce.export_without_send_later
|
||||
|
||||
if ce.workflow_state == 'exported_for_course_copy'
|
||||
# use the exported attachment as the import archive
|
||||
cm.attachment = ce.attachment
|
||||
cm.migration_settings[:migration_ids_to_import] ||= {:copy=>{}}
|
||||
cm.migration_settings[:migration_ids_to_import][:copy][:everything] = true
|
||||
# set any attachments referenced in html to be copied
|
||||
ce.selected_content['attachments'] ||= {}
|
||||
ce.referenced_files.values.each do |att_mig_id|
|
||||
ce.selected_content['attachments'][att_mig_id] = true
|
||||
end
|
||||
ce.save
|
||||
if ce.workflow_state == 'exported_for_course_copy'
|
||||
# use the exported attachment as the import archive
|
||||
cm.attachment = ce.attachment
|
||||
cm.migration_settings[:migration_ids_to_import] ||= {:copy=>{}}
|
||||
cm.migration_settings[:migration_ids_to_import][:copy][:everything] = true
|
||||
# set any attachments referenced in html to be copied
|
||||
ce.selected_content['attachments'] ||= {}
|
||||
ce.referenced_files.values.each do |att_mig_id|
|
||||
ce.selected_content['attachments'][att_mig_id] = true
|
||||
end
|
||||
ce.save
|
||||
|
||||
cm.save
|
||||
worker = Canvas::Migration::Worker::CCWorker.new
|
||||
worker.migration_id = cm.id
|
||||
worker.perform
|
||||
cm.reload
|
||||
if cm.workflow_state == 'exported'
|
||||
cm.workflow_state = :pre_processed
|
||||
cm.update_import_progress(10)
|
||||
|
||||
cm.context.copy_attachments_from_course(source, :content_export => ce, :content_migration => cm)
|
||||
cm.update_import_progress(20)
|
||||
|
||||
cm.import_content
|
||||
cm.workflow_state = :imported
|
||||
cm.save
|
||||
cm.update_import_progress(100)
|
||||
worker = Canvas::Migration::Worker::CCWorker.new
|
||||
worker.migration_id = cm.id
|
||||
worker.perform
|
||||
cm.reload
|
||||
if cm.workflow_state == 'exported'
|
||||
cm.workflow_state = :pre_processed
|
||||
cm.update_import_progress(10)
|
||||
|
||||
cm.context.copy_attachments_from_course(source, :content_export => ce, :content_migration => cm)
|
||||
cm.update_import_progress(20)
|
||||
|
||||
cm.import_content
|
||||
cm.workflow_state = :imported
|
||||
cm.save
|
||||
cm.update_import_progress(100)
|
||||
end
|
||||
else
|
||||
cm.workflow_state = :failed
|
||||
cm.migration_settings[:last_error] = "ContentExport failed to export course."
|
||||
cm.save
|
||||
end
|
||||
else
|
||||
cm.workflow_state = :failed
|
||||
cm.migration_settings[:last_error] = "ContentExport failed to export course."
|
||||
cm.save
|
||||
rescue => e
|
||||
cm.fail_with_error!(e)
|
||||
raise e
|
||||
end
|
||||
rescue => e
|
||||
cm.fail_with_error!(e)
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue