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/Activity/ActivityRepository.cs | |
| parent | 8586c9f6a7dc8562da1f6bca2b3ce53398dd03b5 (diff) | |
| parent | c25db09e37ccdf158e607792cf678b1ed22b13a7 (diff) | |
Merge pull request #2906 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Activity/ActivityRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Activity/ActivityRepository.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 3dcc50ba3..1ae8e5e66 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -10,21 +10,40 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; using SQLitePCL.pretty; using MediaBrowser.Model.Extensions; +using MediaBrowser.Model.IO; namespace Emby.Server.Implementations.Activity { public class ActivityRepository : BaseSqliteRepository, IActivityRepository { private readonly CultureInfo _usCulture = new CultureInfo("en-US"); + protected IFileSystem FileSystem { get; private set; } - public ActivityRepository(ILogger logger, IServerApplicationPaths appPaths) + public ActivityRepository(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem) : base(logger) { DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db"); + FileSystem = fileSystem; } public void Initialize() { + try + { + InitializeInternal(); + } + catch (Exception ex) + { + Logger.ErrorException("Error loading database file. Will reset and retry.", ex); + + FileSystem.DeleteFile(DbFilePath); + + InitializeInternal(); + } + } + + private void InitializeInternal() + { using (var connection = CreateConnection()) { RunDefaultInitialization(connection); |
