diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-10-01 23:35:45 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-01 23:35:45 -0400 |
| commit | a73da532d52ae68ad01965dbf368bacc7d56a218 (patch) | |
| tree | a6f05e95515f822dfc129c36554f74f1da4d4c23 /Emby.Server.Implementations/Activity/ActivityRepository.cs | |
| parent | f651fd6ffba80a6f8e54fca7d014622692cc08f7 (diff) | |
| parent | 796f374359d75e22d2095b3f3a8f9b220cacde27 (diff) | |
Merge pull request #2931 from MediaBrowser/beta
Beta
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); |
