Commit 15703c3f authored by Patricio Cano's avatar Patricio Cano

Fixed rubocop, and moved `delta_size_check` to its own EE only module.

parent c22d40fb
module EE
module Gitlab
module Deltas
def self.delta_size_check(change, repo)
size_of_deltas = 0
begin
tree_a = repo.lookup(change[:oldrev])
tree_b = repo.lookup(change[:newrev])
diff = tree_a.diff(tree_b)
diff.each_delta do |d|
new_file_size = d.deleted? ? 0 : ::Gitlab::Git::Blob.raw(repo, d.new_file[:oid]).size
size_of_deltas += new_file_size
end
size_of_deltas
rescue Rugged::OdbError, Rugged::ReferenceError, Rugged::InvalidError
size_of_deltas
end
end
end
end
end
......@@ -126,7 +126,7 @@ module Gitlab
end
if project.size_limit_enabled?
push_size_in_bytes += delta_size_check(change, project.repository)
push_size_in_bytes += EE::Gitlab::Deltas.delta_size_check(change, project.repository)
end
end
......@@ -137,26 +137,6 @@ module Gitlab
build_status_object(true)
end
def delta_size_check(change, repo)
size_of_deltas = 0
begin
tree_a = repo.lookup(change[:oldrev])
tree_b = repo.lookup(change[:newrev])
diff = tree_a.diff(tree_b)
diff.each_delta do |d|
new_file_size = d.deleted? ? 0 : Gitlab::Git::Blob.raw(repo, d.new_file[:oid]).size
size_of_deltas += new_file_size
end
size_of_deltas
rescue Rugged::OdbError, Rugged::ReferenceError, Rugged::InvalidError
size_of_deltas
end
end
def change_access_check(change)
Checks::ChangeAccess.new(change, user_access: user_access, project: project).exec
end
......@@ -281,4 +261,4 @@ module Gitlab
commit.refs(project.repository).any?
end
end
end
\ No newline at end of file
end
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