Skip to content

Commit e80bcfe

Browse files
authored
Merge pull request #26 from ruby/fix-ruby-list-2882
Workaround ruby-list:2882
2 parents 0794845 + bdd2009 commit e80bcfe

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

app/models/message.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ def self.from_s3(list_name, list_seq)
2121
end
2222

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

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

3134
headers = headers_str.split(/\n/).map { |line|

import.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
message = Message.from_s3(list, seq)
1515
message.save
1616
rescue ActiveRecord::RecordNotUnique
17-
STDERR.puts("#{list}:#{seq} already exists")
17+
STDERR.puts("#{list}:#{seq} already exists in Postgres")
1818
rescue Aws::S3::Errors::NoSuchKey
19-
STDERR.puts("#{list}:#{seq} doesn't exist")
20-
rescue
21-
STDERR.puts("failed to import #{list}:#{seq}")
19+
STDERR.puts("#{list}:#{seq} doesn't exist in S3")
20+
rescue StandardError => e
21+
STDERR.puts("failed to import #{list}:#{seq}: #{e}")
2222
end
2323
end

0 commit comments

Comments
 (0)