@Override public void close() throws IOException { deflater.end(); out.close(); } }
@Override public void close() throws IOException { deflater.end(); out.close(); } }
@Override public void close() throws IOException { deflater.end(); out.close(); } }
private static void writePack(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw, ProgressMonitor pm) throws IOException { DfsOutputStream out = objdb.writeFile(pack, PACK); try { pw.writePack(pm, pm, out); pack.addFileExt(PACK); } finally { out.close(); } }
private static void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw) throws IOException { DfsOutputStream out = objdb.writeFile(pack, INDEX); try { CountingOutputStream cnt = new CountingOutputStream(out); pw.writeIndex(cnt); pack.addFileExt(INDEX); pack.setFileSize(INDEX, cnt.getCount()); pack.setIndexVersion(pw.getIndexVersion()); } finally { out.close(); } }
PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash, List<PackedObjectInfo> list) throws IOException { pack.setIndexVersion(INDEX_VERSION); pack.setObjectCount(list.size()); // If there are less than 58,000 objects, the entire index fits in under // 2 MiB. Callers will probably need the index immediately, so buffer // the index in process and load from the buffer. TemporaryBuffer.Heap buf = null; PackIndex packIndex = null; if (list.size() <= 58000) { buf = new TemporaryBuffer.Heap(2 << 20); index(buf, packHash, list); packIndex = PackIndex.read(buf.openInputStream()); } DfsOutputStream os = db.writeFile(pack, INDEX); try { CountingOutputStream cnt = new CountingOutputStream(os); if (buf != null) buf.writeTo(cnt, null); else index(cnt, packHash, list); pack.addFileExt(INDEX); pack.setFileSize(INDEX, cnt.getCount()); } finally { os.close(); } return packIndex; }