Make import scripts work with frozen strings

This commit is contained in:
Gerhard Schlager 2019-05-30 22:20:57 +02:00
parent c70d0c6659
commit 0f3c3bc309
14 changed files with 19 additions and 17 deletions

View File

@ -255,7 +255,7 @@ class ImportScripts::Answerbase < ImportScripts::Base
upload = @uploader.create_upload(user_id, path, filename) upload = @uploader.create_upload(user_id, path, filename)
if upload.present? && upload.persisted? && !upload_ids.include?(upload.id) if upload.present? && upload.persisted? && !upload_ids.include?(upload.id)
raw << "\n" << @uploader.html_for_upload(upload, filename) raw = "#{raw}\n#{@uploader.html_for_upload(upload, filename)}"
end end
else else
STDERR.puts "Could not find file: #{path}" STDERR.puts "Could not find file: #{path}"

View File

@ -239,7 +239,7 @@ class ImportScripts::MyAskBot < ImportScripts::Base
# ask.cvxr.com/question/(\d+)/[^'"}]* # ask.cvxr.com/question/(\d+)/[^'"}]*
# I am sure this is incomplete, but we didn't make heavy use of internal # I am sure this is incomplete, but we didn't make heavy use of internal
# links on our site. # links on our site.
tmp = Regexp.quote("http://" << OLD_SITE) tmp = Regexp.quote("http://#{OLD_SITE}")
r1 = /"(#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?"/ r1 = /"(#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?"/
r2 = /\((#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?\)/ r2 = /\((#{tmp})?\/question\/(\d+)\/[a-zA-Z-]*\/?\)/
r3 = /<?#tmp\/question\/(\d+)\/[a-zA-Z-]*\/?>?/ r3 = /<?#tmp\/question\/(\d+)\/[a-zA-Z-]*\/?>?/

View File

@ -24,7 +24,7 @@ module ImportScripts
first = true first = true
row = nil row = nil
current_row = "" current_row = +""
double_quote_count = 0 double_quote_count = 0
File.open(filename).each_line do |line| File.open(filename).each_line do |line|

View File

@ -67,7 +67,7 @@ class ImportScripts::Bespoke < ImportScripts::Base
first = true first = true
row = nil row = nil
current_row = "" current_row = +""
double_quote_count = 0 double_quote_count = 0
File.open(filename).each_line do |line| File.open(filename).each_line do |line|

View File

@ -787,7 +787,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
FROM #{table_name 'forum_attachment'} FROM #{table_name 'forum_attachment'}
WHERE pid = #{post.custom_fields['import_id']}" WHERE pid = #{post.custom_fields['import_id']}"
if !inline_attachments.empty? if !inline_attachments.empty?
sql << " AND aid NOT IN (#{inline_attachments.join(',')})" sql = "#{sql} AND aid NOT IN (#{inline_attachments.join(',')})"
end end
results = mysql_query(sql) results = mysql_query(sql)

View File

@ -69,7 +69,7 @@ class ImportScripts::Jive < ImportScripts::Base
first = true first = true
row = nil row = nil
current_row = "" current_row = +""
double_quote_count = 0 double_quote_count = 0
File.open(filename).each_line do |line| File.open(filename).each_line do |line|

View File

@ -129,7 +129,7 @@ class ImportScripts::JiveApi < ImportScripts::Base
filters = "filter=entityDescriptor(#{entities.join(",")})" filters = "filter=entityDescriptor(#{entities.join(",")})"
else else
path = "places/#{place["placeID"]}/contents" path = "places/#{place["placeID"]}/contents"
filters = "filter=status(published)" filters = +"filter=status(published)"
if to_import[:filters] if to_import[:filters]
filters << "&filter=type(#{to_import[:filters][:type]})" if to_import[:filters][:type].present? filters << "&filter=type(#{to_import[:filters][:type]})" if to_import[:filters][:type].present?
filters << "&filter=creationDate(null,#{to_import[:filters][:created_after].strftime("%Y-%m-%dT%TZ")})" if to_import[:filters][:created_after].present? filters << "&filter=creationDate(null,#{to_import[:filters][:created_after].strftime("%Y-%m-%dT%TZ")})" if to_import[:filters][:created_after].present?

View File

@ -1021,7 +1021,7 @@ SQL
end end
def html_for_attachments(user_id, files) def html_for_attachments(user_id, files)
html = "" html = +""
files.each do |file| files.each do |file|
upload, filename = find_upload(user_id, file["attachment_id"], file["file_name"]) upload, filename = find_upload(user_id, file["attachment_id"], file["file_name"])

View File

@ -137,7 +137,7 @@ module ImportScripts::Mbox
body = receiver.add_attachments(body, user) body = receiver.add_attachments(body, user)
end end
body << Email::Receiver.elided_html(elided) if elided.present? body = "#{body}#{Email::Receiver.elided_html(elided)}" if elided.present?
body body
end end

View File

@ -155,7 +155,7 @@ module ImportScripts::Mbox
end end
def each_mail(filename) def each_mail(filename)
raw_message = '' raw_message = +''
first_line_number = 1 first_line_number = 1
last_line_number = 0 last_line_number = 0
@ -165,7 +165,7 @@ module ImportScripts::Mbox
if line =~ @split_regex if line =~ @split_regex
if last_line_number > 0 if last_line_number > 0
yield raw_message, first_line_number, last_line_number yield raw_message, first_line_number, last_line_number
raw_message = '' raw_message = +''
first_line_number = last_line_number + 1 first_line_number = last_line_number + 1
end end
else else

View File

@ -283,7 +283,7 @@ class String
def indent(count, char = ' ') def indent(count, char = ' ')
gsub(/([^\n]*)(\n|$)/) do |match| gsub(/([^\n]*)(\n|$)/) do |match|
last_iteration = ($1 == "" && $2 == "") last_iteration = ($1 == "" && $2 == "")
line = "" line = +""
line << (char * count) unless last_iteration line << (char * count) unless last_iteration
line << $1 line << $1
line << $2 line << $2

View File

@ -26,8 +26,10 @@ module ImportScripts::PhpBB3
require_relative 'database_3_1' require_relative 'database_3_1'
Database_3_1.new(@database_client, @database_settings) Database_3_1.new(@database_client, @database_settings)
else else
raise UnsupportedVersionError, "Unsupported version (#{version}) of phpBB detected.\n" \ raise UnsupportedVersionError, <<~MSG
<< 'Currently only 3.0.x and 3.1.x are supported by this importer.' Unsupported version (#{version}) of phpBB detected.
Currently only 3.0.x and 3.1.x are supported by this importer.
MSG
end end
end end

View File

@ -56,7 +56,7 @@ module ImportScripts::PhpBB3
# @param poll_data [ImportScripts::PhpBB3::PollData] # @param poll_data [ImportScripts::PhpBB3::PollData]
def get_poll_text(poll_data) def get_poll_text(poll_data)
title = @text_processor.process_raw_text(poll_data.title) title = @text_processor.process_raw_text(poll_data.title)
text = "#{title}\n\n" text = +"#{title}\n\n"
arguments = ["results=always"] arguments = ["results=always"]
arguments << "close=#{poll_data.close_time.iso8601}" if poll_data.close_time arguments << "close=#{poll_data.close_time.iso8601}" if poll_data.close_time

View File

@ -319,7 +319,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
"\n[#{tag}]#{$~[:inner].strip}[/#{tag}]\n" "\n[#{tag}]#{$~[:inner].strip}[/#{tag}]\n"
end end
body.gsub!(XListPattern) do |s| body.gsub!(XListPattern) do |s|
r = "\n[ul]" r = +"\n[ul]"
s.lines.each { |l| r << '[li]' << l.strip.sub(/^\[x\]\s*/, '') << '[/li]' } s.lines.each { |l| r << '[li]' << l.strip.sub(/^\[x\]\s*/, '') << '[/li]' }
r << "[/ul]\n" r << "[/ul]\n"
end end
@ -357,7 +357,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
inner = $~[:inner].strip inner = $~[:inner].strip
params = parse_tag_params($~[:params]) params = parse_tag_params($~[:params])
if params['author'].present? if params['author'].present?
quote = "[quote=\"#{params['author']}" quote = +"[quote=\"#{params['author']}"
if QuoteParamsPattern =~ params['link'] if QuoteParamsPattern =~ params['link']
tl = topic_lookup_from_imported_post_id($~[:msg].to_i) tl = topic_lookup_from_imported_post_id($~[:msg].to_i)
quote << ", post:#{tl[:post_number]}, topic:#{tl[:topic_id]}" if tl quote << ", post:#{tl[:post_number]}, topic:#{tl[:topic_id]}" if tl