Line data Source code
1 : // Copyright (C) 2010 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.git; 16 : 17 : import com.google.gerrit.server.config.ConfigUtil; 18 : import com.google.gerrit.server.config.GerritServerConfig; 19 : import com.google.inject.Inject; 20 : import com.google.inject.Singleton; 21 : import java.util.concurrent.TimeUnit; 22 : import org.eclipse.jgit.lib.Config; 23 : import org.eclipse.jgit.storage.pack.PackConfig; 24 : 25 : @Singleton 26 : public class TransferConfig { 27 : private final int timeout; 28 : private final PackConfig packConfig; 29 : private final long maxObjectSizeLimit; 30 : private final String maxObjectSizeLimitFormatted; 31 : private final boolean inheritProjectMaxObjectSizeLimit; 32 : 33 : @Inject 34 151 : TransferConfig(@GerritServerConfig Config cfg) { 35 151 : timeout = 36 : (int) 37 151 : ConfigUtil.getTimeUnit( 38 : cfg, 39 : "transfer", 40 : null, 41 : "timeout", // 42 : 0, 43 : TimeUnit.SECONDS); 44 151 : maxObjectSizeLimit = cfg.getLong("receive", "maxObjectSizeLimit", 0); 45 151 : maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit"); 46 151 : inheritProjectMaxObjectSizeLimit = 47 151 : cfg.getBoolean("receive", "inheritProjectMaxObjectSizeLimit", false); 48 : 49 151 : packConfig = new PackConfig(); 50 151 : packConfig.setDeltaCompress(false); 51 151 : packConfig.setThreads(1); 52 151 : packConfig.fromConfig(cfg); 53 151 : } 54 : 55 : /** Returns configured timeout, in seconds. 0 if the timeout is infinite. */ 56 : public int getTimeout() { 57 134 : return timeout; 58 : } 59 : 60 : public PackConfig getPackConfig() { 61 134 : return packConfig; 62 : } 63 : 64 : public long getMaxObjectSizeLimit() { 65 151 : return maxObjectSizeLimit; 66 : } 67 : 68 : public String getFormattedMaxObjectSizeLimit() { 69 0 : return maxObjectSizeLimitFormatted; 70 : } 71 : 72 : public boolean inheritProjectMaxObjectSizeLimit() { 73 151 : return inheritProjectMaxObjectSizeLimit; 74 : } 75 : }