mirror of
https://github.com/discourse/discourse.git
synced 2025-09-04 08:47:37 +08:00
Improvements to mbox import script
* Ignore errors during indexing and show information about the message causing the problem * Always activate imported users if they aren't staged
This commit is contained in:
parent
bdb25338e5
commit
dc32ee5cbf
2 changed files with 38 additions and 27 deletions
|
@ -70,7 +70,7 @@ module ImportScripts::Mbox
|
|||
name: row['name'],
|
||||
trust_level: @settings.trust_level,
|
||||
staged: @settings.staged,
|
||||
active: false,
|
||||
active: !@settings.staged,
|
||||
created_at: to_time(row['date_of_first_message'])
|
||||
}
|
||||
end
|
||||
|
|
|
@ -62,6 +62,7 @@ module ImportScripts::Mbox
|
|||
|
||||
def index_emails(directory, category_name)
|
||||
all_messages(directory, category_name) do |receiver, filename, opts|
|
||||
begin
|
||||
msg_id = receiver.message_id
|
||||
parsed_email = receiver.mail
|
||||
from_email, from_display_name = receiver.parse_from_field(parsed_email)
|
||||
|
@ -91,6 +92,16 @@ module ImportScripts::Mbox
|
|||
db.insert_email(email)
|
||||
db.insert_replies(msg_id, reply_message_ids) unless reply_message_ids.empty?
|
||||
end
|
||||
rescue StandardError => e
|
||||
if opts[:first_line_number] && opts[:last_line_number]
|
||||
STDERR.puts "Failed to index message in #{filename} at lines #{opts[:first_line_number]}-#{opts[:last_line_number]}"
|
||||
else
|
||||
STDERR.puts "Failed to index message in #{filename}"
|
||||
end
|
||||
|
||||
STDERR.puts e.message
|
||||
STDERR.puts e.backtrace.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue