Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9756deec
Commit
9756deec
authored
Jun 28, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix optimization
parent
4949edce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+1
-1
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+16
-0
No files found.
lib/gitlab/shell.rb
View file @
9756deec
...
...
@@ -253,7 +253,7 @@ module Gitlab
ids_in_file
.
uniq!
keys_in_db
=
Key
.
where
(
id:
ids_in_file
)
return
unless
ids_in_file
.
size
>
keys_in_db
.
count
# optimization
next
unless
ids_in_file
.
size
>
keys_in_db
.
count
# optimization
ids_to_remove
=
ids_in_file
-
keys_in_db
.
pluck
(
:id
)
ids_to_remove
.
each
do
|
id
|
...
...
spec/lib/gitlab/shell_spec.rb
View file @
9756deec
...
...
@@ -326,6 +326,22 @@ describe Gitlab::Shell, lib: true do
gitlab_shell
.
remove_keys_not_found_in_db
end
end
unless
ENV
[
'CI'
]
# Skip in CI, it takes 1 minute
context
'when the first batch can be skipped, but the next batch has keys that are not in the DB'
do
before
do
gitlab_shell
.
remove_all_keys
100
.
times
{
|
i
|
create
(
:key
)
}
# first batch is all in the DB
gitlab_shell
.
add_key
(
'key-1234'
,
'ssh-rsa ASDFASDF'
)
end
it
'removes the keys not in the DB'
do
expect
(
find_in_authorized_keys_file
(
1234
)).
to
be_truthy
gitlab_shell
.
remove_keys_not_found_in_db
expect
(
find_in_authorized_keys_file
(
1234
)).
to
be_falsey
end
end
end
end
describe
'#batch_read_key_ids'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment