diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-19 18:50:54 +0300 |
---|---|---|
committer | Ian Baum <ibaum@gitlab.com> | 2018-02-23 21:04:57 +0300 |
commit | f1d4f08b27eaeb30fb3697995ec2d8b8b14f6486 (patch) | |
tree | 4744a5af9eeb376f373eaf779cef1263c60631a3 /lib | |
parent | 0fe7ef299d86e16eeb722cf25f8f23b3fdf454a4 (diff) |
Merge branch 'jej/avoid-slow-file-lock-checks' into 'master'
Avoid slow File Lock checks when not used
Closes #43339
See merge request gitlab-org/gitlab-ce!17140
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/checks/change_access.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/checks/commit_check.rb | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb index 521680b8708..3ce5f807989 100644 --- a/lib/gitlab/checks/change_access.rb +++ b/lib/gitlab/checks/change_access.rb @@ -121,6 +121,7 @@ module Gitlab def commits_check return if deletion? || newrev.nil? + return unless should_run_commit_validations? # n+1: https://gitlab.com/gitlab-org/gitlab-ee/issues/3593 ::Gitlab::GitalyClient.allow_n_plus_1_calls do @@ -139,6 +140,10 @@ module Gitlab private + def should_run_commit_validations? + commit_check.validate_lfs_file_locks? + end + def updated_from_web? protocol == 'web' end @@ -176,7 +181,7 @@ module Gitlab end def commits - project.repository.new_commits(newrev) + @commits ||= project.repository.new_commits(newrev) end end end diff --git a/lib/gitlab/checks/commit_check.rb b/lib/gitlab/checks/commit_check.rb index ae0cd142378..43a52b493bb 100644 --- a/lib/gitlab/checks/commit_check.rb +++ b/lib/gitlab/checks/commit_check.rb @@ -35,14 +35,14 @@ module Gitlab end end - private - def validate_lfs_file_locks? strong_memoize(:validate_lfs_file_locks) do project.lfs_enabled? && project.lfs_file_locks.any? && newrev && oldrev end end + private + def lfs_file_locks_validation lambda do |paths| lfs_lock = project.lfs_file_locks.where(path: paths).where.not(user_id: user.id).first |