diff options
Diffstat (limited to 'app/models/lfs_object.rb')
-rw-r--r-- | app/models/lfs_object.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 6a86aebae39..c5233deaa96 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -17,6 +17,8 @@ class LfsObject < ApplicationRecord mount_uploader :file, LfsObjectUploader + before_save :set_file_store, if: ->(lfs_object) { lfs_object.file_store.nil? } + after_save :update_file_store, if: :saved_change_to_file? def self.not_linked_to_project(project) @@ -55,6 +57,17 @@ class LfsObject < ApplicationRecord def self.calculate_oid(path) self.hexdigest(path) end + + private + + def set_file_store + self.file_store = + if LfsObjectUploader.object_store_enabled? && LfsObjectUploader.direct_upload_enabled? + LfsObjectUploader::Store::REMOTE + else + file.object_store + end + end end LfsObject.prepend_if_ee('EE::LfsObject') |