From 000c172553a874d6a790c6237dd0b55d29c27218 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 12 Apr 2014 17:00:08 +0200 Subject: [PATCH] Fixed: Moved main database cleanup to daily housekeeping to prevent windows service startup failure. --- src/NzbDrone.Core/Datastore/DbFactory.cs | 6 ------ src/NzbDrone.Core/Housekeeping/HousekeepingService.cs | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Datastore/DbFactory.cs b/src/NzbDrone.Core/Datastore/DbFactory.cs index 6d0e4a615..df7889d83 100644 --- a/src/NzbDrone.Core/Datastore/DbFactory.cs +++ b/src/NzbDrone.Core/Datastore/DbFactory.cs @@ -78,12 +78,6 @@ public IDatabase Create(MigrationType migrationType = MigrationType.Main) return dataMapper; }); - - if (migrationType == MigrationType.Main) - { - db.Vacuum(); - } - return db; } } diff --git a/src/NzbDrone.Core/Housekeeping/HousekeepingService.cs b/src/NzbDrone.Core/Housekeeping/HousekeepingService.cs index 26725a2c9..b48e953e0 100644 --- a/src/NzbDrone.Core/Housekeeping/HousekeepingService.cs +++ b/src/NzbDrone.Core/Housekeeping/HousekeepingService.cs @@ -4,6 +4,7 @@ using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Datastore; namespace NzbDrone.Core.Housekeeping { @@ -11,11 +12,13 @@ public class HousekeepingService : IExecute, IHandleAsync _housekeepers; private readonly Logger _logger; + private readonly IDatabase _mainDb; - public HousekeepingService(IEnumerable housekeepers, Logger logger) + public HousekeepingService(IEnumerable housekeepers, Logger logger, IDatabase mainDb) { _housekeepers = housekeepers; _logger = logger; + _mainDb = mainDb; } private void Clean() @@ -33,6 +36,10 @@ private void Clean() _logger.ErrorException("Error running housekeeping task: " + housekeeper.GetType().FullName, ex); } } + + // Vacuuming the log db isn't needed since that's done hourly at the TrimLogCommand. + _logger.Debug("Compressing main database after housekeeping"); + _mainDb.Vacuum(); } public void Execute(HousekeepingCommand message)