Lucene.Net.Index.TestSnapshotDeletionPolicy.BackupIndex C# (CSharp) Method

BackupIndex() public method

Example showing how to use the SnapshotDeletionPolicy to take a backup. this method does not really do a backup; instead, it reads every byte of every file just to test that the files indeed exist and are readable even while the index is changing.
public BackupIndex ( Directory dir, Lucene.Net.Index.SnapshotDeletionPolicy dp ) : void
dir Directory
dp Lucene.Net.Index.SnapshotDeletionPolicy
return void
        public virtual void BackupIndex(Directory dir, SnapshotDeletionPolicy dp)
        {
            // To backup an index we first take a snapshot:
            IndexCommit snapshot = dp.Snapshot();
            try
            {
                CopyFiles(dir, snapshot);
            }
            finally
            {
                // Make sure to release the snapshot, otherwise these
                // files will never be deleted during this IndexWriter
                // session:
                dp.Release(snapshot);
            }
        }