From a41d850df67750738cbc542636f9b501bc6619c2 Mon Sep 17 00:00:00 2001 From: zmn Date: Sun, 2 Apr 2017 18:22:56 +0200 Subject: [PATCH] fixed problem on already existent file index. --- Wlog.Library/BLL/Index/LuceneIndexManager.cs | 5 ++++- Wlog.Library/BLL/Reporitories/IndexRepository.cs | 5 +---- Wlog.Web/Global.asax.cs | 6 +++--- Wlog.Web/Web.config | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Wlog.Library/BLL/Index/LuceneIndexManager.cs b/Wlog.Library/BLL/Index/LuceneIndexManager.cs index a096758..2771ddc 100644 --- a/Wlog.Library/BLL/Index/LuceneIndexManager.cs +++ b/Wlog.Library/BLL/Index/LuceneIndexManager.cs @@ -113,7 +113,10 @@ private void InitIndex() { logger.Debug("[IndexManager] InitIndex"); - + if (!string.IsNullOrEmpty(Path) && !System.IO.Directory.Exists(Path)) + { + System.IO.Directory.CreateDirectory(Path); + } logger.Debug("[IndexManager] Opening {0}", Path); luceneIndexDirectory = settings.GetLuceneIndexDirectory(Path); logger.Debug("[IndexManager] Creating IndexWriter"); diff --git a/Wlog.Library/BLL/Reporitories/IndexRepository.cs b/Wlog.Library/BLL/Reporitories/IndexRepository.cs index 1e58f9c..dab6955 100644 --- a/Wlog.Library/BLL/Reporitories/IndexRepository.cs +++ b/Wlog.Library/BLL/Reporitories/IndexRepository.cs @@ -78,10 +78,7 @@ private void CreateIndex(string name) var path = Path.Combine(BasePath, name); var idx = new LuceneIndexManager(name, path); idx.CommitSize = int.MaxValue; //commit is owned by the caller. - if (!Directory.Exists(idx.Path)) - { - Directory.CreateDirectory(idx.Path); - } + indexList.Add(name,idx ); } diff --git a/Wlog.Web/Global.asax.cs b/Wlog.Web/Global.asax.cs index ef449e4..1b83bcf 100644 --- a/Wlog.Web/Global.asax.cs +++ b/Wlog.Web/Global.asax.cs @@ -51,7 +51,8 @@ protected void Application_Start() if (installed) { - + _logger.Info("Setup index configuration"); + IndexRepository.BasePath = HttpContext.Current.Server.MapPath("~/App_Data/Index/"); _logger.Info("Apply schema changes"); RepositoryContext.Current.System.ApplySchemaChanges(); @@ -68,8 +69,7 @@ protected void Application_Start() HangfireBootstrapper.Instance.Start(); - _logger.Info("Setup index configuration"); - IndexRepository.BasePath = HttpContext.Current.Server.MapPath("~/App_Data/Index/"); + _logger.Info("Insert seed data"); diff --git a/Wlog.Web/Web.config b/Wlog.Web/Web.config index 878eed7..62312ed 100644 --- a/Wlog.Web/Web.config +++ b/Wlog.Web/Web.config @@ -47,7 +47,7 @@ NHibernate.Driver.SqlClientDriver - Server=(localdb)\Projects;initial catalog=HubLink2;Integrated Security=true; + Server=(localdb)\Projects;initial catalog=WebLog_develop;Integrated Security=true; NHibernate.Dialect.MsSql2012Dialect thread_static on_close @@ -79,7 +79,7 @@ - +