aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
index 89664d158..1901ce848 100644
--- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
@@ -19,12 +19,14 @@ namespace Emby.Server.Implementations.Data
public class SqliteDisplayPreferencesRepository : BaseSqliteRepository, IDisplayPreferencesRepository
{
private readonly IMemoryStreamFactory _memoryStreamProvider;
+ protected IFileSystem FileSystem { get; private set; }
- public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IMemoryStreamFactory memoryStreamProvider)
+ public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IMemoryStreamFactory memoryStreamProvider, IFileSystem fileSystem)
: base(logger)
{
_jsonSerializer = jsonSerializer;
_memoryStreamProvider = memoryStreamProvider;
+ FileSystem = fileSystem;
DbFilePath = Path.Combine(appPaths.DataPath, "displaypreferences.db");
}
@@ -45,11 +47,27 @@ namespace Emby.Server.Implementations.Data
/// </summary>
private readonly IJsonSerializer _jsonSerializer;
+ public void Initialize()
+ {
+ try
+ {
+ InitializeInternal();
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error loading database file. Will reset and retry.", ex);
+
+ FileSystem.DeleteFile(DbFilePath);
+
+ InitializeInternal();
+ }
+ }
+
/// <summary>
/// Opens the connection to the database
/// </summary>
/// <returns>Task.</returns>
- public void Initialize()
+ private void InitializeInternal()
{
using (var connection = CreateConnection())
{