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
a303eafb
Commit
a303eafb
authored
Oct 11, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce a new EE::Concerns::LfsRequest module
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ad2d9189
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
app/controllers/concerns/lfs_request.rb
app/controllers/concerns/lfs_request.rb
+1
-36
ee/app/controllers/concerns/ee/lfs_request.rb
ee/app/controllers/concerns/ee/lfs_request.rb
+35
-0
No files found.
app/controllers/concerns/lfs_request.rb
View file @
a303eafb
...
...
@@ -11,6 +11,7 @@ module LfsRequest
extend
ActiveSupport
::
Concern
included
do
prepend
EE
::
LfsRequest
before_action
:require_lfs_enabled!
before_action
:lfs_check_access!
end
...
...
@@ -111,40 +112,4 @@ module LfsRequest
def
has_authentication_ability?
(
capability
)
(
authentication_abilities
||
[]).
include?
(
capability
)
end
module
EE
def
lfs_forbidden!
raise
NotImplementedError
unless
defined?
(
super
)
if
project
.
above_size_limit?
||
objects_exceed_repo_limit?
render_size_error
else
super
end
end
def
render_size_error
render
(
json:
{
message:
Gitlab
::
RepositorySizeError
.
new
(
project
).
push_error
(
@exceeded_limit
),
documentation_url:
help_url
},
content_type:
"application/vnd.git-lfs+json"
,
status:
406
)
end
def
objects_exceed_repo_limit?
return
false
unless
project
.
size_limit_enabled?
return
@limit_exceeded
if
defined?
(
@limit_exceeded
)
lfs_push_size
=
objects
.
sum
{
|
o
|
o
[
:size
]
}
size_with_lfs_push
=
project
.
repository_and_lfs_size
+
lfs_push_size
@exceeded_limit
=
size_with_lfs_push
-
project
.
actual_size_limit
@limit_exceeded
=
@exceeded_limit
>
0
end
end
prepend
EE
end
ee/app/controllers/concerns/ee/lfs_request.rb
0 → 100644
View file @
a303eafb
module
EE
module
LfsRequest
extend
ActiveSupport
::
Concern
def
lfs_forbidden!
if
project
.
above_size_limit?
||
objects_exceed_repo_limit?
render_size_error
else
super
end
end
def
render_size_error
render
(
json:
{
message:
::
Gitlab
::
RepositorySizeError
.
new
(
project
).
push_error
(
@exceeded_limit
),
documentation_url:
help_url
},
content_type:
"application/vnd.git-lfs+json"
,
status:
406
)
end
def
objects_exceed_repo_limit?
return
false
unless
project
.
size_limit_enabled?
return
@limit_exceeded
if
defined?
(
@limit_exceeded
)
lfs_push_size
=
objects
.
sum
{
|
o
|
o
[
:size
]
}
size_with_lfs_push
=
project
.
repository_and_lfs_size
+
lfs_push_size
@exceeded_limit
=
size_with_lfs_push
-
project
.
actual_size_limit
@limit_exceeded
=
@exceeded_limit
>
0
end
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