Allow per project maxObjectSizeLimit.
Project owners can define receive.maxObjectSizeLimit in their project.config in order to further restrict the global receive.maxObjectSizeLimit setting from etc/gerrit.config. The project specific maxObjectSizeLimit is only honored if smaller than the global maxObjectSizeLimit, otherwise it is ignored. Change-Id: Ia14354e0c9b6bfb4fa62295162e8f2c127b09997
This commit is contained in:
@@ -94,7 +94,7 @@ final class Receive extends AbstractGitCommand {
|
||||
final ReceivePack rp = receive.getReceivePack();
|
||||
rp.setRefLogIdent(currentUser.newRefLogIdent());
|
||||
rp.setTimeout(config.getTimeout());
|
||||
rp.setMaxObjectSizeLimit(config.getMaxObjectSizeLimit());
|
||||
rp.setMaxObjectSizeLimit(getMaxObjectSizeLimit());
|
||||
try {
|
||||
receive.advertiseHistory();
|
||||
rp.receive(in, out, err);
|
||||
@@ -170,4 +170,15 @@ final class Receive extends AbstractGitCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getMaxObjectSizeLimit() {
|
||||
long global = config.getMaxObjectSizeLimit();
|
||||
long local = projectControl.getProjectState().getMaxObjectSizeLimit();
|
||||
if (global > 0 && local > 0) {
|
||||
return Math.min(global, local);
|
||||
} else {
|
||||
// zero means "no limit", in this case the max is more limiting
|
||||
return Math.max(global, local);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user