Showing wrong exceeding value on push when rejected
Summary
When trying to push a file to LFS and it exceeds the repository size limit, we get this:
batch response: http: Your push has been rejected, because this repository has exceeded its size limit of 40 MB by -2193050 Bytes. Please contact your GitLab administrator for more information.
After some debugging, I've found that we calculate it correctly on LfsRequest#objects_exceed_repo_limit?
, but when showing the error message on Gitlab::RepositorySizeError
, we use project#repository_and_lfs_size
, that rely on ProjectStatistics#lfs_objects_size
which is 0
at this point, because we still don't have this size persisted yet.
Steps to reproduce
- Change the size limit of a project to a value close to being exceeded (e.g.: If the repo has 30mb, change the repository size limit to 35mb)
- Push a file to LFS that will exceed 35mb
git lfs track file.rar
git push origin test-limit-branch
Expected behavior
The correct value that exceeds the limit. If the limit is 40MB, we're already using 35MB and we push a 10MB file, we should get:
batch response: http: Your push has been rejected, because this repository has exceeded its size limit of 40 MB by 5 MB. Please contact your GitLab administrator for more information.
Actual behavior
batch response: http: Your push has been rejected, because this repository has exceeded its size limit of 40 MB by -2193050 Bytes. Please contact your GitLab administrator for more information.