summaryrefslogtreecommitdiff
path: root/app/uploaders/pages/deployment_uploader.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /app/uploaders/pages/deployment_uploader.rb
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
downloadgitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/uploaders/pages/deployment_uploader.rb')
-rw-r--r--app/uploaders/pages/deployment_uploader.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/uploaders/pages/deployment_uploader.rb b/app/uploaders/pages/deployment_uploader.rb
new file mode 100644
index 00000000000..e510025fc7d
--- /dev/null
+++ b/app/uploaders/pages/deployment_uploader.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+module Pages
+ class DeploymentUploader < GitlabUploader
+ include ObjectStorage::Concern
+
+ storage_options Gitlab.config.pages
+
+ alias_method :upload, :model
+
+ private
+
+ def dynamic_segment
+ Gitlab::HashedPath.new('pages_deployments', model.id, root_hash: model.project_id)
+ end
+
+ # @hashed is chosen to avoid conflict with namespace name because we use the same directory for storage
+ # @ is not valid character for namespace
+ def base_dir
+ "@hashed"
+ end
+
+ # override GitlabUploader
+ # if set to true it erases the original file when uploading
+ # and we copy from the artifacts archive, so artifacts end up
+ # without the file
+ def move_to_cache
+ false
+ end
+
+ class << self
+ # we only upload this files from the rails background job
+ # so we don't need direct upload for pages deployments
+ # this method is here to ignore any user setting
+ def direct_upload_enabled?
+ false
+ end
+
+ # we don't need background uploads because we upload files
+ # to the right store right away, and we already do that in
+ # the background job
+ def background_upload_enabled?
+ false
+ end
+
+ def default_store
+ object_store_enabled? ? ObjectStorage::Store::REMOTE : ObjectStorage::Store::LOCAL
+ end
+ end
+ end
+end