diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-09-22 01:54:57 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-09-22 01:54:57 -0400 |
| commit | 2d29d903be8af52a953bf847e1f6b168fbb236cc (patch) | |
| tree | 9b67efb87bb011c69115790441f11ed97cb9cad2 /Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs | |
| parent | e5f340d6b7c914428e6b68ec1bbfeb9e27234b32 (diff) | |
fixes #2904 - disabling transcoding for a user is not working
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()) { |
