/// <summary> /// Create an index pack instance to load a new pack into a repository. /// <para/> /// The received pack data and generated index will be saved to temporary /// files within the repository's <code>objects</code> directory. To use the /// data contained within them call <see cref="renameAndOpenPack()"/> once the /// indexing is complete. /// </summary> /// <param name="db">the repository that will receive the new pack.</param> /// <param name="stream"> /// stream to read the pack data from. If the stream is buffered /// use <see cref="BUFFER_SIZE"/> as the buffer size for the stream. /// </param> /// <returns>a new index pack instance.</returns> internal static IndexPack Create(Repository db, Stream stream) { DirectoryInfo objdir = db.ObjectsDirectory; FileInfo tmp = CreateTempFile("incoming_", PackSuffix, objdir); string n = tmp.Name; var basef = PathUtil.CombineFilePath(objdir, n.Slice(0, n.Length - PackSuffix.Length)); var ip = new IndexPack(db, stream, basef); ip.setIndexVersion(db.Config.getCore().getPackIndexVersion()); return(ip); }
internal static IndexPack Create(Repository db, Stream stream) { DirectoryInfo objdir = db.ObjectsDirectory; FileInfo tmp = CreateTempFile("incoming_", PackSuffix, objdir); string n = tmp.Name; var basef = new FileInfo(Path.Combine(objdir.FullName, n.Slice(0, n.Length - PackSuffix.Length))); var ip = new IndexPack(db, stream, basef); ip.setIndexVersion(db.Config.getCore().getPackIndexVersion()); return ip; }
private void VerifyOpenPack(bool thin) { IndexPack indexer; Stream @is; if (thin) { @is = new MemoryStream(_os.ToArray()); indexer = new IndexPack(db, @is, _packBase); try { indexer.index(new TextProgressMonitor()); Assert.Fail("indexer should grumble about missing object"); } catch (IOException) { // expected } } @is = new MemoryStream(_os.ToArray()); indexer = new IndexPack(db, @is, _packBase); indexer.setKeepEmpty(true); indexer.setFixThin(thin); indexer.setIndexVersion(2); indexer.index(new TextProgressMonitor()); _pack = new PackFile(_indexFile, _packFile); }