Exemplo n.º 1
0
  private void receivePack() throws IOException {
    // It might take the client a while to pack the objects it needs
    // to send to us.  We should increase our timeout so we don't
    // abort while the client is computing.
    //
    if (timeoutIn != null) timeoutIn.setTimeout(10 * timeout * 1000);

    ProgressMonitor receiving = NullProgressMonitor.INSTANCE;
    ProgressMonitor resolving = NullProgressMonitor.INSTANCE;
    if (sideBand) resolving = new SideBandProgressMonitor(msgOut);

    ObjectInserter ins = db.newObjectInserter();
    try {
      String lockMsg = "jgit receive-pack";
      if (getRefLogIdent() != null) lockMsg += " from " + getRefLogIdent().toExternalString();

      parser = ins.newPackParser(rawIn);
      parser.setAllowThin(true);
      parser.setNeedNewObjectIds(checkReferencedIsReachable);
      parser.setNeedBaseObjectIds(checkReferencedIsReachable);
      parser.setCheckEofAfterPackFooter(!biDirectionalPipe);
      parser.setObjectChecking(isCheckReceivedObjects());
      parser.setLockMessage(lockMsg);
      parser.setMaxObjectSizeLimit(maxObjectSizeLimit);
      packLock = parser.parse(receiving, resolving);
      ins.flush();
    } finally {
      ins.release();
    }

    if (timeoutIn != null) timeoutIn.setTimeout(timeout * 1000);
  }
  private void openPack(TemporaryBuffer.Heap buf) throws IOException {
    if (inserter == null) inserter = src.newObjectInserter();

    final byte[] raw = buf.toByteArray();
    PackParser p = inserter.newPackParser(new ByteArrayInputStream(raw));
    p.setAllowThin(true);
    p.parse(PM);
  }