static void SetStream(LF e, System.IO.TextWriter w) { if (w == null) { w = System.IO.TextWriter.Null; } m_out[(int)e] = w; }
internal static void RestoreIndex(bool force, System.IO.TextWriter consoleOut) { using (var optrace = new OperationTrace("Restore index")) { var recoveredZipPath = IO.Path.Combine(_backupDirectoryPath, RECOVEREDFILENAME); var recoveredFilesPath = IO.Path.Combine(_backupDirectoryPath, COMPRESSIONROOT); Guid lastIdFromDb; var need = NeedRestore(out lastIdFromDb); if (force || need) { EnsureEmptyDirctory(_backupDirectoryPath); RecoverIndexBackupFromDb(recoveredZipPath); DecompressTheIndex(recoveredZipPath, _backupDirectoryPath); var dir = ContentRepository.Storage.IndexDirectory.CreateNew(); //EnsureEmptyDirctory(IndexDirectoryPath); MoveDirectoryContent(recoveredFilesPath, dir); SaveBackupIdToFile(lastIdFromDb, IO.Path.Combine(dir, RESTOREINFOFILENAME)); ContentRepository.Storage.IndexDirectory.Reset(); ContentRepository.Storage.IndexDirectory.RemoveUnnecessaryDirectories(); if (consoleOut != null) { consoleOut.WriteLine(" Index directory is restored."); consoleOut.WriteLine(" Path: {0},", IndexDirectoryPath); consoleOut.WriteLine(" BackupId: {0},", lastIdFromDb); } Logger.WriteInformation(EventId.Indexing.SuccessfullyRestored, "Index directory is successfully restored.", properties: new Dictionary <string, object> { { "BackupId", lastIdFromDb } }); } else { if (consoleOut != null) { consoleOut.WriteLine(" Index directory restoring is skipped."); } Logger.WriteVerbose("Index directory restoring is skipped.", new Dictionary <string, object> { { "BackupId", lastIdFromDb } }); } optrace.IsSuccessful = true; } }