mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-27 00:02:25 +00:00
Fixed: Slower startup loop on DB initialization failure
Wrap any exception thrown in a LidarrStartupException to trigger the existing bootloop code. We have to catch the generic Exception class since FluentMigrator rethrows all exceptions as a generic Exception.
This commit is contained in:
parent
d7e406dccb
commit
59cc5584c6
1 changed files with 10 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
using NzbDrone.Common.Composition;
|
using NzbDrone.Common.Composition;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Common.Exceptions;
|
||||||
using NzbDrone.Common.Instrumentation;
|
using NzbDrone.Common.Instrumentation;
|
||||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ private static void InitializeEnvironment()
|
||||||
Environment.SetEnvironmentVariable("No_PreLoadSQLite", "true");
|
Environment.SetEnvironmentVariable("No_PreLoadSQLite", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterDatabase(IContainer container)
|
public static void RegisterDatabase(IContainer container)
|
||||||
{
|
{
|
||||||
var mainDb = new MainDatabase(container.Resolve<IDbFactory>().Create());
|
var mainDb = new MainDatabase(container.Resolve<IDbFactory>().Create());
|
||||||
|
|
||||||
|
@ -127,6 +128,10 @@ private void CreateMain(string connectionString, MigrationContext migrationConte
|
||||||
|
|
||||||
throw new CorruptDatabaseException("Database file: {0} is corrupt, restore from backup if available. See: https://github.com/Lidarr/Lidarr/wiki/FAQ#i-am-getting-an-error-database-disk-image-is-malformed", e, fileName);
|
throw new CorruptDatabaseException("Database file: {0} is corrupt, restore from backup if available. See: https://github.com/Lidarr/Lidarr/wiki/FAQ#i-am-getting-an-error-database-disk-image-is-malformed", e, fileName);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new LidarrStartupException(e, "Error creating main database");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateLog(string connectionString, MigrationContext migrationContext)
|
private void CreateLog(string connectionString, MigrationContext migrationContext)
|
||||||
|
@ -155,6 +160,10 @@ private void CreateLog(string connectionString, MigrationContext migrationContex
|
||||||
|
|
||||||
_migrationController.Migrate(connectionString, migrationContext);
|
_migrationController.Migrate(connectionString, migrationContext);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new LidarrStartupException(e, "Error creating log database");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue