Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 16:16:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 16:16:36 +0300
commit311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch)
tree07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/uploaded_file.rb
parent27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff)
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/uploaded_file.rb')
-rw-r--r--lib/uploaded_file.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/uploaded_file.rb b/lib/uploaded_file.rb
index 79920968603..36baf4a3cf8 100644
--- a/lib/uploaded_file.rb
+++ b/lib/uploaded_file.rb
@@ -20,8 +20,9 @@ class UploadedFile
attr_reader :remote_id
attr_reader :sha256
attr_reader :size
+ attr_reader :upload_duration
- def initialize(path, filename: nil, content_type: "application/octet-stream", sha256: nil, remote_id: nil, size: nil)
+ def initialize(path, filename: nil, content_type: "application/octet-stream", sha256: nil, remote_id: nil, size: nil, upload_duration: nil)
if path.present?
raise InvalidPathError, "#{path} file does not exist" unless ::File.exist?(path)
@@ -35,6 +36,12 @@ class UploadedFile
end
end
+ begin
+ @upload_duration = Float(upload_duration)
+ rescue ArgumentError, TypeError
+ @upload_duration = 0
+ end
+
@content_type = content_type
@original_filename = sanitize_filename(filename || path || '')
@content_type = content_type
@@ -64,8 +71,11 @@ class UploadedFile
content_type: params['type'] || 'application/octet-stream',
sha256: params['sha256'],
remote_id: remote_id,
- size: params['size']
- )
+ size: params['size'],
+ upload_duration: params['upload_duration']
+ ).tap do |uploaded_file|
+ ::Gitlab::Instrumentation::Uploads.track(uploaded_file)
+ end
end
def self.allowed_path?(file_path, paths)