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
f48aff81
Commit
f48aff81
authored
Apr 07, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expire snippet repo size caching for push
Replace uncached_size call
parent
32eb78d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
7 deletions
+4
-7
app/models/snippet.rb
app/models/snippet.rb
+1
-1
app/workers/post_receive.rb
app/workers/post_receive.rb
+1
-5
spec/models/snippet_spec.rb
spec/models/snippet_spec.rb
+1
-1
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+1
-0
No files found.
app/models/snippet.rb
View file @
f48aff81
...
@@ -267,7 +267,7 @@ class Snippet < ApplicationRecord
...
@@ -267,7 +267,7 @@ class Snippet < ApplicationRecord
def
repository_size_checker
def
repository_size_checker
strong_memoize
(
:repository_size_checker
)
do
strong_memoize
(
:repository_size_checker
)
do
::
Gitlab
::
RepositorySizeChecker
.
new
(
::
Gitlab
::
RepositorySizeChecker
.
new
(
current_size_proc:
->
{
repository
.
_uncached_
size
.
megabytes
},
current_size_proc:
->
{
repository
.
size
.
megabytes
},
limit:
Gitlab
::
CurrentSettings
.
snippet_size_limit
limit:
Gitlab
::
CurrentSettings
.
snippet_size_limit
)
)
end
end
...
...
app/workers/post_receive.rb
View file @
f48aff81
...
@@ -77,12 +77,8 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
...
@@ -77,12 +77,8 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
return
false
unless
user
return
false
unless
user
# At the moment, we only expires the repository caches.
# In the future we might need to call ProjectCacheWorker
# (or the custom class we create) to update the snippet
# repository size or any other key.
# We might also need to update the repository statistics.
expire_caches
(
post_received
,
snippet
.
repository
)
expire_caches
(
post_received
,
snippet
.
repository
)
snippet
.
repository
.
expire_statistics_caches
end
end
# Expire the repository status, branch, and tag cache once per push.
# Expire the repository status, branch, and tag cache once per push.
...
...
spec/models/snippet_spec.rb
View file @
f48aff81
...
@@ -703,7 +703,7 @@ describe Snippet do
...
@@ -703,7 +703,7 @@ describe Snippet do
let
(
:current_size
)
{
60
}
let
(
:current_size
)
{
60
}
before
do
before
do
allow
(
subject
.
repository
).
to
receive
(
:
_uncached_
size
).
and_return
(
current_size
)
allow
(
subject
.
repository
).
to
receive
(
:size
).
and_return
(
current_size
)
end
end
it
'sets up size checker'
,
:aggregate_failures
do
it
'sets up size checker'
,
:aggregate_failures
do
...
...
spec/workers/post_receive_spec.rb
View file @
f48aff81
...
@@ -394,6 +394,7 @@ describe PostReceive do
...
@@ -394,6 +394,7 @@ describe PostReceive do
it
'expires the status cache'
do
it
'expires the status cache'
do
expect
(
snippet
.
repository
).
to
receive
(
:empty?
).
and_return
(
true
)
expect
(
snippet
.
repository
).
to
receive
(
:empty?
).
and_return
(
true
)
expect
(
snippet
.
repository
).
to
receive
(
:expire_status_cache
)
expect
(
snippet
.
repository
).
to
receive
(
:expire_status_cache
)
expect
(
snippet
.
repository
).
to
receive
(
:expire_statistics_caches
)
perform
perform
end
end
...
...
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