From a0b0f586c87af56c2d97f0be85afc207a216d322 Mon Sep 17 00:00:00 2001 From: kayone Date: Wed, 27 Nov 2013 23:11:41 -0800 Subject: [PATCH] New: Log database is compressed when logs are trimmed/purged --- .../Scene/SceneMappingServiceFixture.cs | 6 +++--- src/NzbDrone.Core/Instrumentation/LogRepository.cs | 1 + src/NzbDrone.Core/Instrumentation/LogService.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs b/src/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs index 55bed6ad5..66a5a900a 100644 --- a/src/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs @@ -35,7 +35,7 @@ public void Setup() _fakeMappings[4].ParseTerm = "Cleaned"; } - + [Test] public void UpdateMappings_purge_existing_mapping_and_add_new_ones() @@ -80,14 +80,14 @@ public void UpdateMappings_should_not_delete_if_fetch_returns_empty_list() private void AssertNoUpdate() { Mocker.GetMock().Verify(c => c.Fetch(), Times.Once()); - Mocker.GetMock().Verify(c => c.Purge(), Times.Never()); + Mocker.GetMock().Verify(c => c.Purge(It.IsAny()), Times.Never()); Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Never()); } private void AssertMappingUpdated() { Mocker.GetMock().Verify(c => c.Fetch(), Times.Once()); - Mocker.GetMock().Verify(c => c.Purge(), Times.Once()); + Mocker.GetMock().Verify(c => c.Purge(It.IsAny()), Times.Once()); Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Once()); diff --git a/src/NzbDrone.Core/Instrumentation/LogRepository.cs b/src/NzbDrone.Core/Instrumentation/LogRepository.cs index 62d2d3a0e..2ec69d26c 100644 --- a/src/NzbDrone.Core/Instrumentation/LogRepository.cs +++ b/src/NzbDrone.Core/Instrumentation/LogRepository.cs @@ -21,6 +21,7 @@ public void Trim() { var trimDate = DateTime.UtcNow.AddDays(-7).Date; Delete(c => c.Time <= trimDate); + Vacuum(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Instrumentation/LogService.cs b/src/NzbDrone.Core/Instrumentation/LogService.cs index 7f9000847..cf5237771 100644 --- a/src/NzbDrone.Core/Instrumentation/LogService.cs +++ b/src/NzbDrone.Core/Instrumentation/LogService.cs @@ -30,7 +30,7 @@ public void Execute(TrimLogCommand message) public void Execute(ClearLogCommand message) { - _logRepository.Purge(); + _logRepository.Purge(vacuum: true); } } } \ No newline at end of file