summaryrefslogtreecommitdiff
path: root/app/uploaders
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-04-03 17:34:14 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-04-04 23:13:45 +0200
commit9dde7df2470cc3fe7989de163fe3985d53262a0d (patch)
tree2214d86cdd95c4af5ae91dd5ec3b07a8be14df0f /app/uploaders
parenteaed588bf228c833cb666a61bc7d25cf21d5f94b (diff)
downloadgitlab-ce-9dde7df2470cc3fe7989de163fe3985d53262a0d.tar.gz
Allow to store uploads by default on Object Storagedirect-upload-of-uploads
Introduce `direct_upload` option for `uploads` which is gonna set a default storage to Object Storage and use Unicorn to save data
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/object_storage.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index 4028b052768..3f59ee39299 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -128,7 +128,7 @@ module ObjectStorage
end
def direct_upload_enabled?
- object_store_options.direct_upload
+ object_store_options&.direct_upload
end
def background_upload_enabled?
@@ -184,6 +184,14 @@ module ObjectStorage
StoreURL: connection.put_object_url(remote_store_path, upload_path, expire_at, options)
}
end
+
+ def default_object_store
+ if self.object_store_enabled? && self.direct_upload_enabled?
+ Store::REMOTE
+ else
+ Store::LOCAL
+ end
+ end
end
# allow to configure and overwrite the filename
@@ -204,12 +212,12 @@ module ObjectStorage
end
def object_store
- @object_store ||= model.try(store_serialization_column) || Store::LOCAL
+ @object_store ||= model.try(store_serialization_column) || self.class.default_object_store
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def object_store=(value)
- @object_store = value || Store::LOCAL
+ @object_store = value || self.class.default_object_store
@storage = storage_for(object_store)
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables