diff options
Diffstat (limited to 'Emby.Server.Implementations/Social/SharingRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Social/SharingRepository.cs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/Social/SharingRepository.cs b/Emby.Server.Implementations/Social/SharingRepository.cs index f306e76c4..f0b8cbd30 100644 --- a/Emby.Server.Implementations/Social/SharingRepository.cs +++ b/Emby.Server.Implementations/Social/SharingRepository.cs @@ -7,22 +7,42 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Model.Social; using SQLitePCL.pretty; using MediaBrowser.Model.Extensions; +using MediaBrowser.Model.IO; namespace Emby.Server.Implementations.Social { public class SharingRepository : BaseSqliteRepository, ISharingRepository { - public SharingRepository(ILogger logger, IApplicationPaths appPaths) + protected IFileSystem FileSystem { get; private set; } + + public SharingRepository(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem) : base(logger) { + FileSystem = fileSystem; DbFilePath = Path.Combine(appPaths.DataPath, "shares.db"); } + 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()) { |
