summaryrefslogtreecommitdiff
path: root/app/models/lfs_object.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/lfs_object.rb')
-rw-r--r--app/models/lfs_object.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index 60b11ad9356..535c3cf2ba1 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -2,6 +2,7 @@
class LfsObject < ApplicationRecord
include AfterCommitQueue
+ include Checksummable
include EachBatch
include ObjectStorage::BackgroundMove
@@ -9,6 +10,7 @@ class LfsObject < ApplicationRecord
has_many :projects, -> { distinct }, through: :lfs_objects_projects
scope :with_files_stored_locally, -> { where(file_store: LfsObjectUploader::Store::LOCAL) }
+ scope :with_files_stored_remotely, -> { where(file_store: LfsObjectUploader::Store::REMOTE) }
validates :oid, presence: true, uniqueness: true
@@ -23,7 +25,13 @@ class LfsObject < ApplicationRecord
end
def project_allowed_access?(project)
- projects.exists?(project.lfs_storage_project.id)
+ if project.fork_network_member
+ lfs_objects_projects
+ .where("EXISTS(?)", project.fork_network.fork_network_members.select(1).where("fork_network_members.project_id = lfs_objects_projects.project_id"))
+ .exists?
+ else
+ lfs_objects_projects.where(project_id: project.id).exists?
+ end
end
def local_store?
@@ -39,7 +47,7 @@ class LfsObject < ApplicationRecord
# rubocop: enable DestroyAll
def self.calculate_oid(path)
- Digest::SHA256.file(path).hexdigest
+ self.hexdigest(path)
end
end