summaryrefslogtreecommitdiff
path: root/app/models/upload.rb
diff options
context:
space:
mode:
authorMicaël Bergeron <mbergeron@gitlab.com>2018-01-29 16:06:17 -0500
committerMicaël Bergeron <mbergeron@gitlab.com>2018-02-02 09:28:15 -0500
commit74ddc80590053b04b90c35ae3e1f46bfbd9d0d15 (patch)
tree145eaf19ac0a06a7bb8e5a0d85b97606ccaf77eb /app/models/upload.rb
parent54a575f1bbba44573ab92dc58a4242f1ee734c5d (diff)
downloadgitlab-ce-74ddc80590053b04b90c35ae3e1f46bfbd9d0d15.tar.gz
add the uploader context to the upload model
Diffstat (limited to 'app/models/upload.rb')
-rw-r--r--app/models/upload.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/models/upload.rb b/app/models/upload.rb
index fb55fd8007b..28baee95091 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -30,7 +30,8 @@ class Upload < ActiveRecord::Base
end
def build_uploader
- uploader_class.new(model).tap do |uploader|
+ uploader_class.new(model, mount_point, **uploader_context)
+ .tap do |uploader|
uploader.upload = self
uploader.retrieve_from_store!(identifier)
end
@@ -40,6 +41,13 @@ class Upload < ActiveRecord::Base
File.exist?(absolute_path)
end
+ def uploader_context
+ {
+ identifier: identifier,
+ secret: secret
+ }.compact
+ end
+
private
def checksummable?
@@ -62,11 +70,15 @@ class Upload < ActiveRecord::Base
!path.start_with?('/')
end
+ def uploader_class
+ Object.const_get(uploader)
+ end
+
def identifier
File.basename(path)
end
- def uploader_class
- Object.const_get(uploader)
+ def mount_point
+ super&.to_sym
end
end