From 0f1d348d683fdef6c36c3b244c85e59f582ff886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mica=C3=ABl=20Bergeron?= Date: Wed, 21 Feb 2018 11:43:21 -0500 Subject: port the object storage to CE --- app/models/lfs_object.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/models/lfs_object.rb') diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 65c157d61ca..04c75d827e0 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -1,10 +1,12 @@ class LfsObject < ActiveRecord::Base - prepend EE::LfsObject include AfterCommitQueue + include ObjectStorage::BackgroundMove has_many :lfs_objects_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :lfs_objects_projects + scope :with_files_stored_locally, -> { where(file_store: [nil, LfsObjectUploader::Store::LOCAL]) } + validates :oid, presence: true, uniqueness: true scope :with_files_stored_locally, -> { where(file_store: [nil, LfsObjectUploader::Store::LOCAL]) } @@ -21,6 +23,10 @@ class LfsObject < ActiveRecord::Base projects.exists?(project.lfs_storage_project.id) end + def local_store? + [nil, LfsObjectUploader::Store::LOCAL].include?(self.file_store) + end + def self.destroy_unreferenced joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id") .where(lfs_objects_projects: { id: nil }) -- cgit v1.2.1