diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-09-22 16:35:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-22 16:35:54 -0400 |
| commit | a31006577432efd25de2fe0e32a3900af7b0907a (patch) | |
| tree | 60cde7a83b451889dcfb7dc88f02df6ffd6e90f1 /Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs | |
| parent | 8586c9f6a7dc8562da1f6bca2b3ce53398dd03b5 (diff) | |
| parent | c25db09e37ccdf158e607792cf678b1ed22b13a7 (diff) | |
Merge pull request #2906 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs | 22 |
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()) { |
