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
69df9d7b
Commit
69df9d7b
authored
Jun 05, 2019
by
Patrick Bajao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abort immediately when limit gets reached
parent
894157ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
ee/lib/ee/gitlab/git_access.rb
ee/lib/ee/gitlab/git_access.rb
+17
-11
No files found.
ee/lib/ee/gitlab/git_access.rb
View file @
69df9d7b
...
...
@@ -84,7 +84,7 @@ module EE
def
check_push_size!
return
unless
check_size_limit?
# Use #
quarantine_size to get correct push size whenever a lof
of changes
# Use #
check_quarantine_size to get correct push size whenever a lot
of changes
# gets pushed at the same time containing the same blobs. This is only
# doable if GIT_OBJECT_DIRECTORY_RELATIVE env var is set and happens
# when git push comes from CLI (not via UI and API).
...
...
@@ -92,10 +92,10 @@ module EE
# Fallback to determining push size using the changes_list so we can still
# determine the push size if env var isn't set (e.g. changes are made
# via UI and API).
push_size
=
check_quarantine_size?
?
quarantine_size
:
changes_size
if
project
.
changes_will_exceed_size_limit?
(
push_size
)
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
::
Gitlab
::
RepositorySizeError
.
new
(
project
).
new_changes_error
if
check_quarantine_size?
check_quarantine_size
else
check_changes_size
end
end
...
...
@@ -107,23 +107,29 @@ module EE
end
end
def
quarantine_size
project
.
repository
.
object_directory_size
def
check_
quarantine_size
check_size_against_limit
(
project
.
repository
.
object_directory_size
)
end
def
changes_size
def
ch
eck_ch
anges_size
# If there are worktrees with a HEAD pointing to a non-existent object,
# calls to `git rev-list --all` will fail in git 2.15+. This should also
# clear stale lock files.
project
.
repository
.
clean_stale_repository_files
size_in_bytes
=
0
changes_size
=
0
changes_list
.
each
do
|
change
|
size_in_bytes
+=
repository
.
new_blobs
(
change
[
:newrev
]).
sum
(
&
:size
)
# rubocop: disable CodeReuse/ActiveRecord
changes_size
+=
repository
.
new_blobs
(
change
[
:newrev
]).
sum
(
&
:size
)
# rubocop: disable CodeReuse/ActiveRecord
check_size_against_limit
(
changes_size
)
end
end
size_in_bytes
def
check_size_against_limit
(
size
)
if
project
.
changes_will_exceed_size_limit?
(
size
)
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
::
Gitlab
::
RepositorySizeError
.
new
(
project
).
new_changes_error
end
end
def
check_size_limit?
...
...
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