diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake index 465ca9958..ae8d3bb66 100644 --- a/lib/tasks/migrate_from_mantis.rake +++ b/lib/tasks/migrate_from_mantis.rake @@ -503,10 +503,17 @@ task :migrate_from_mantis => :environment do # Make sure bugs can refer bugs in other projects Setting.cross_project_issue_relations = 1 if Setting.respond_to? 'cross_project_issue_relations' - # Turn off email notifications - Setting.notified_events = [] + old_notified_events = Setting.notified_events + begin + # Turn off email notifications temporarily + Setting.notified_events = [] + # Run the migration + MantisMigrate.establish_connection db_params + MantisMigrate.migrate + ensure + # Restore previous notification settings even if the migration fails + Setting.notified_events = old_notified_events + end - MantisMigrate.establish_connection db_params - MantisMigrate.migrate end end diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 923b0c620..406a5b221 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -762,10 +762,16 @@ namespace :redmine do prompt('Target project identifier') {|identifier| TracMigrate.target_project_identifier identifier} puts - # Turn off email notifications - Setting.notified_events = [] - - TracMigrate.migrate + old_notified_events = Setting.notified_events + begin + # Turn off email notifications temporarily + Setting.notified_events = [] + # Run the migration + TracMigrate.migrate + ensure + # Restore previous notification settings even if the migration fails + Setting.notified_events = old_notified_events + end end end