List of usage examples for org.eclipse.jgit.transport ReceivePack setMaxPackSizeLimit
public void setMaxPackSizeLimit(long limit)
From source file:com.googlesource.gerrit.plugins.quota.MaxRepositorySizeQuota.java
License:Apache License
@Override public void init(Project.NameKey project, ReceivePack rp) { QuotaSection quotaSection = quotaFinder.firstMatching(project); if (quotaSection == null) { return;// w w w . j a v a2 s. co m } Long maxRepoSize = quotaSection.getMaxRepoSize(); Long maxTotalSize = quotaSection.getMaxTotalSize(); if (maxRepoSize == null && maxTotalSize == null) { return; } try { Long maxPackSize1 = null; if (maxRepoSize != null) { maxPackSize1 = Math.max(0, maxRepoSize - cache.get(project).get()); } Long maxPackSize2 = null; if (maxTotalSize != null) { long totalSize = 0; for (Project.NameKey p : projectCache.all()) { if (quotaSection.matches(p)) { totalSize += cache.get(p).get(); } } maxPackSize2 = Math.max(0, maxTotalSize - totalSize); } long maxPackSize = Ordering.<Long>natural().nullsLast().min(maxPackSize1, maxPackSize2); rp.setMaxPackSizeLimit(maxPackSize); } catch (ExecutionException e) { log.warn("Couldn't setMaxPackSizeLimit on receive-pack for " + project.get(), e); } }