public bool Check(AbstractConnection connection) { var hashCode = connection.Folder.GetHashCode(); if (Checks.ContainsKey(hashCode)) { return Checks[hashCode]; } try { using (var indexDirectory = LuceneDirectoryFactory.Create(connection, connection.TflBatchEntity(_processName))) { using (var reader = IndexReader.Open(indexDirectory, true)) { connection.Logger.Debug("Successfully connected to lucene index in {0}.", connection.Folder); Checks[hashCode] = true; return true; } } } catch (Exception ex) { _logger.Warn("Failed to connect to a lucene index in {0}.", connection.Folder); _logger.Debug(ex.Message); var exists = new DirectoryInfo(connection.Folder).Exists; Checks[hashCode] = exists; return exists; } }
public bool Check(AbstractConnection connection) { var hashCode = connection.Folder.GetHashCode(); if (Checks.ContainsKey(hashCode)) { return(Checks[hashCode]); } try { using (var indexDirectory = LuceneDirectoryFactory.Create(connection, connection.TflBatchEntity(_processName))) { using (var reader = IndexReader.Open(indexDirectory, true)) { connection.Logger.Debug("Successfully connected to lucene index in {0}.", connection.Folder); Checks[hashCode] = true; return(true); } } } catch (Exception ex) { _logger.Warn("Failed to connect to a lucene index in {0}.", connection.Folder); _logger.Debug(ex.Message); var exists = new DirectoryInfo(connection.Folder).Exists; Checks[hashCode] = exists; return(exists); } }