diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 21:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 21:09:13 +0000 |
commit | e49bd57279b72cf517853aec369e341fa3442d60 (patch) | |
tree | 91b544f03a49c1aa7d1d072f30226031f841cfb0 /app | |
parent | 139d707cfeb007f3cf30f39a38deb0eec6817a47 (diff) | |
download | gitlab-ce-e49bd57279b72cf517853aec369e341fa3442d60.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request_diff.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index ba51f2bd822..eb5250d5cf6 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -493,6 +493,8 @@ class MergeRequestDiff < ApplicationRecord self.stored_externally = true rows + ensure + tempfile&.unlink end def create_merge_request_diff_files(rows) @@ -503,19 +505,17 @@ class MergeRequestDiff < ApplicationRecord end def build_external_diff_tempfile(rows) - pos = 0 + Tempfile.open(external_diff.filename) do |file| + rows.each do |row| + data = row.delete(:diff) + row[:external_diff_offset] = file.pos + row[:external_diff_size] = data.bytesize - segments = rows.map do |row| - segment = row.delete(:diff) - - row[:external_diff_offset] = pos - row[:external_diff_size] = segment.bytesize - pos += segment.bytesize + file.write(data) + end - segment + file end - - CarrierWaveStringFile.new(segments.join(''), external_diff.filename) end def build_merge_request_diff_files(diffs) |