Commit b7b82dce authored by Nick Thomas's avatar Nick Thomas

Revert "Merge branch '216458-remove-tempfile-from-external-diff-creation' into 'master'"

This reverts merge request !35750
parent c75c0662
......@@ -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)
......
---
title: Remove tempfile from external diff creation
merge_request: 35750
author:
type: performance
# frozen_string_literal: true
class CarrierWaveStringFile < StringIO
attr_reader :original_filename
def initialize(data, original_filename = "")
super(data)
@original_filename = original_filename
def original_filename
""
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment