Skip to content
代码片段 群组 项目
未验证 提交 18b39458 编辑于 作者: Brian Williams's avatar Brian Williams 提交者: GitLab
浏览文件

Merge branch 'minac_write_lines_with_semaphore' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -67,6 +67,7 @@ def finalise_segmented_export
Async do
semaphore = Async::Semaphore.new(NUMBER_OF_CONCURRENT_TASKS)
write_semaphore = Async::Semaphore.new
tasks = vulnerability_export.export_parts.map do |part|
semaphore.async do
......@@ -74,13 +75,15 @@ def finalise_segmented_export
stream.readline if export_header.present? # Moves the cursor to next line
stream.each_line do |line|
# The encoding of the parts is read as ASCI-8BIT.
# We need to force the encoding to utf-8 to avoid a write failure due to
# wide-chars used in place like group names.
# See:
# https://github.com/carrierwaveuploader/carrierwave/issues/1583
# https://gitlab.com/gitlab-org/gitlab/-/blob/0aa846a1baa08b1f6f11b2711f8f6bf880542a46/lib/gitlab/http_io.rb
tempfile << line.force_encoding(Encoding::UTF_8)
write_semaphore.acquire do
# The encoding of the parts is read as ASCI-8BIT.
# We need to force the encoding to utf-8 to avoid a write failure due to
# wide-chars used in place like group names.
# See:
# https://github.com/carrierwaveuploader/carrierwave/issues/1583
# https://gitlab.com/gitlab-org/gitlab/-/blob/0aa846a1baa08b1f6f11b2711f8f6bf880542a46/lib/gitlab/http_io.rb
tempfile << line.force_encoding(Encoding::UTF_8)
end
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册