From 6936f042f53889539612c08ecb9d02a3a73bb568 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 20 May 2013 21:10:04 -0700 Subject: [PATCH] disable model events for log repository --- NzbDrone.Core/Datastore/BasicRepository.cs | 8 +++++++- NzbDrone.Core/Datastore/Events/ModelEvent.cs | 13 ++++++------- NzbDrone.Core/Instrumentation/LogRepository.cs | 5 +++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs index a983e8f03..a2c07813a 100644 --- a/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -106,7 +106,7 @@ namespace NzbDrone.Core.Datastore } DataMapper.Insert(model); - _messageAggregator.PublishEvent(new ModelEvent(model, ModelEvent.RepositoryAction.Created)); + PublishModelEvent(model, RepositoryAction.Created); return model; } @@ -193,5 +193,11 @@ namespace NzbDrone.Core.Datastore .Execute(); } + + protected virtual void PublishModelEvent(TModel model, RepositoryAction action) + { + _messageAggregator.PublishEvent(new ModelEvent(model, action)); + } + } } diff --git a/NzbDrone.Core/Datastore/Events/ModelEvent.cs b/NzbDrone.Core/Datastore/Events/ModelEvent.cs index 8e7b9fcb7..c5ef20daa 100644 --- a/NzbDrone.Core/Datastore/Events/ModelEvent.cs +++ b/NzbDrone.Core/Datastore/Events/ModelEvent.cs @@ -13,14 +13,13 @@ namespace NzbDrone.Core.Datastore.Events Model = model; Action = action; } + } - - public enum RepositoryAction - { - Created = 1, - Updated = 2, - Deleted = 3 - } + public enum RepositoryAction + { + Created = 1, + Updated = 2, + Deleted = 3 } diff --git a/NzbDrone.Core/Instrumentation/LogRepository.cs b/NzbDrone.Core/Instrumentation/LogRepository.cs index abba443e8..4858eaedd 100644 --- a/NzbDrone.Core/Instrumentation/LogRepository.cs +++ b/NzbDrone.Core/Instrumentation/LogRepository.cs @@ -23,5 +23,10 @@ namespace NzbDrone.Core.Instrumentation var oldIds = Query.Where(c => c.Time < DateTime.Now.AddDays(-30).Date).Select(c => c.Id); DeleteMany(oldIds); } + + protected override void PublishModelEvent(Log model, Datastore.Events.RepositoryAction action) + { + //Don't publish log added events. + } } } \ No newline at end of file