blob: d16c068c3c0cf71ccb8fdd5d8fd13df2617fadf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# frozen_string_literal: true
module Gitlab
module Middleware
class RackMultipartTempfileFactory
# Immediately unlink the created temporary file so we don't have to rely
# on Rack::TempfileReaper catching this after the fact.
FACTORY = lambda do |filename, content_type|
Rack::Multipart::Parser::TEMPFILE_FACTORY.call(filename, content_type).tap(&:unlink)
end
def initialize(app)
@app = app
end
def call(env)
if ENV['GITLAB_TEMPFILE_IMMEDIATE_UNLINK'] == '1'
env[Rack::RACK_MULTIPART_TEMPFILE_FACTORY] = FACTORY
end
@app.call(env)
end
end
end
end
|