Commit f48aff81 authored by Mark Chao's avatar Mark Chao

Expire snippet repo size caching for push

Replace uncached_size call
parent 32eb78d7
......@@ -267,7 +267,7 @@ class Snippet < ApplicationRecord
def repository_size_checker
strong_memoize(:repository_size_checker) do
::Gitlab::RepositorySizeChecker.new(
current_size_proc: -> { repository._uncached_size.megabytes },
current_size_proc: -> { repository.size.megabytes },
limit: Gitlab::CurrentSettings.snippet_size_limit
)
end
......
......@@ -77,12 +77,8 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
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)
snippet.repository.expire_statistics_caches
end
# Expire the repository status, branch, and tag cache once per push.
......
......@@ -703,7 +703,7 @@ describe Snippet do
let(:current_size) { 60 }
before do
allow(subject.repository).to receive(:_uncached_size).and_return(current_size)
allow(subject.repository).to receive(:size).and_return(current_size)
end
it 'sets up size checker', :aggregate_failures do
......
......@@ -394,6 +394,7 @@ describe PostReceive do
it 'expires the status cache' do
expect(snippet.repository).to receive(:empty?).and_return(true)
expect(snippet.repository).to receive(:expire_status_cache)
expect(snippet.repository).to receive(:expire_statistics_caches)
perform
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment