Repository.size returns a wrong result
Most probably it's related to cache but I'm not 100% sure.
We (me and @jnijhof) measured an actual result with
def measure
total_size = 0
Project.where("id < 200").each do |p|
path_to_repo = File.expand_path(File.join(Gitlab.config.gitlab_shell.repos_path, p.path_with_namespace + ".git"))
size = `du -sk #{path_to_repo}|awk '{ print $1}'`
total_size = total_size + size.chomp.to_i
end
total_size / 1024
end
measure
For example Project.where("id < 200").sum(:repository_size)
returns 23.51MB where real size is 488MB