Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ def self.from_s3(list_name, list_seq)
end

def self.from_string(str)
headers_str, body = str.split(/\n\n/, 2)
# There are a few hacks to import messages from blade.ruby-lang.org's
# S3 bucket.

# Not really sure this is from the original email, or while making
# blade.ruby-lang.org's S3 archive, but there are emails without
# a proper Form header, such as ruby-list:2840.
# Need to call String#b. There are messages that have headers in non-UTF8,
# but the body is in UTF-8, such as ruby-list:2882.
headers_str, body = str.b.split(/\n\n/, 2)

# ruby-list:2840 doesn't have a proper From header.
headers_str = Kconv.toutf8(headers_str).gsub(/\r\n/, '')

headers = headers_str.split(/\n/).map { |line|
Expand Down
8 changes: 4 additions & 4 deletions import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
message = Message.from_s3(list, seq)
message.save
rescue ActiveRecord::RecordNotUnique
STDERR.puts("#{list}:#{seq} already exists")
STDERR.puts("#{list}:#{seq} already exists in Postgres")
rescue Aws::S3::Errors::NoSuchKey
STDERR.puts("#{list}:#{seq} doesn't exist")
rescue
STDERR.puts("failed to import #{list}:#{seq}")
STDERR.puts("#{list}:#{seq} doesn't exist in S3")
rescue StandardError => e
STDERR.puts("failed to import #{list}:#{seq}: #{e}")
end
end