The Free Software Media System - Server Backend & API
update db migration
Luke Pulverentid28ef71d93ea
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.csindex d91d80dbd1..a11eb3aaa7 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs@@ -241,7 +241,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer}catch (Exception errorEx){- _logger.ErrorException("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx);+ //_logger.ErrorException("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx);}}@@ -350,10 +350,12 @@ namespace MediaBrowser.Server.Implementations.HttpServerif (!string.IsNullOrWhiteSpace(GlobalResponse)){- httpRes.Write(GlobalResponse);- httpRes.ContentType = "text/plain";-- if (!string.Equals(GetExtension(urlString), "html", StringComparison.OrdinalIgnoreCase))+ if (string.Equals(GetExtension(urlString), "html", StringComparison.OrdinalIgnoreCase))+ {+ httpRes.Write(GlobalResponse);+ httpRes.ContentType = "text/plain";+ }+ else{httpRes.StatusCode = 503;}diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.csindex 5c600c249f..0959e2123c 100644--- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs@@ -67,7 +67,8 @@ namespace MediaBrowser.Server.Implementations.Persistence{OnProgress(0);- // Ensure these objects are out of the database.+ // Ensure these objects are lazy loaded.+ // Without this there is a deadlock that will need to be investigatedvar rootChildren = _libraryManager.RootFolder.Children.ToList();rootChildren = _libraryManager.GetUserRootFolder().Children.ToList();@@ -182,14 +183,6 @@ namespace MediaBrowser.Server.Implementations.Persistenceprogress.Report(100);}- private void LogMessage(string msg)- {- if (EnableUnavailableMessage)- {- _logger.Info(msg);- }- }-private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress<double> progress){var itemIds = _libraryManager.GetItemIds(new InternalItemsQuerydiff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.csindex 3dc37110e4..7898dc1ef5 100644--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs@@ -583,22 +583,16 @@ namespace MediaBrowser.Server.Implementations.PersistenceCheckDisposed();- _logger.Info("SaveItems waiting on write lock");-await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);IDbTransaction transaction = null;try{- _logger.Info("SaveItems creating transaction");-transaction = _connection.BeginTransaction();foreach (var item in items){- _logger.Info("Saving {0}", item.Id);-cancellationToken.ThrowIfCancellationRequested();var index = 0;diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 46dfd4469f..36d15b95a5 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -317,7 +317,8 @@ namespace MediaBrowser.Server.Startup.Common/// <returns>Task.</returns>public override async Task RunStartupTasks(){- if (ServerConfigurationManager.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)+ if (ServerConfigurationManager.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&+ ServerConfigurationManager.Configuration.IsStartupWizardCompleted){TaskManager.SuspendTriggers = true;}diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.csindex 5a70467f75..3cd92bcde8 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs@@ -18,7 +18,8 @@ namespace MediaBrowser.Server.Startup.Common.Migrationspublic void Run(){- if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)+ if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&+ _config.Configuration.IsStartupWizardCompleted){_taskManager.SuspendTriggers = true;CleanDatabaseScheduledTask.EnableUnavailableMessage = true;