Commit d69694e8 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Simplify repo limit convertion from MBs to Bytes

parent d4bc570e
...@@ -2,7 +2,8 @@ module ApplicationSettings ...@@ -2,7 +2,8 @@ module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService class UpdateService < ApplicationSettings::BaseService
def execute def execute
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
assign_repository_size_limit_as_bytes(@application_setting) limit = @params.delete(:repository_size_limit)
@application_setting.repository_size_limit = (limit.to_i.megabytes if limit.present?)
@application_setting.update(@params) @application_setting.update(@params)
end end
......
...@@ -46,13 +46,6 @@ class BaseService ...@@ -46,13 +46,6 @@ class BaseService
private private
def assign_repository_size_limit_as_bytes(model)
repository_size_limit = @params.delete(:repository_size_limit)
new_value = repository_size_limit.to_i.megabytes if repository_size_limit.present?
model.repository_size_limit = new_value
end
def error(message, http_status = nil) def error(message, http_status = nil)
result = { result = {
message: message, message: message,
......
...@@ -13,7 +13,8 @@ module Groups ...@@ -13,7 +13,8 @@ module Groups
end end
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
assign_repository_size_limit_as_bytes(@group) limit = params.delete(:repository_size_limit)
@group.repository_size_limit = (limit.to_i.megabytes if limit.present?)
if @group.parent && !can?(current_user, :admin_group, @group.parent) if @group.parent && !can?(current_user, :admin_group, @group.parent)
@group.parent = nil @group.parent = nil
......
...@@ -13,7 +13,8 @@ module Groups ...@@ -13,7 +13,8 @@ module Groups
end end
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
assign_repository_size_limit_as_bytes(group) limit = @params.delete(:repository_size_limit)
group.repository_size_limit = (limit.to_i.megabytes if limit.present?)
group.assign_attributes(params) group.assign_attributes(params)
......
...@@ -23,7 +23,8 @@ module Projects ...@@ -23,7 +23,8 @@ module Projects
end end
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
assign_repository_size_limit_as_bytes(@project) limit = params.delete(:repository_size_limit)
@project.repository_size_limit = (limit.to_i.megabytes if limit.present?)
# Set project name from path # Set project name from path
if @project.name.present? && @project.path.present? if @project.name.present? && @project.path.present?
......
...@@ -14,7 +14,8 @@ module Projects ...@@ -14,7 +14,8 @@ module Projects
end end
# Repository size limit comes as MB from the view # Repository size limit comes as MB from the view
assign_repository_size_limit_as_bytes(project) limit = params.delete(:repository_size_limit)
project.repository_size_limit = (limit.to_i.megabytes if limit.present?)
new_branch = params.delete(:default_branch) new_branch = params.delete(:default_branch)
new_repository_storage = params.delete(:repository_storage) new_repository_storage = params.delete(:repository_storage)
......
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