From bd4856dad8a7b55dff35d21b83887b628c38707b Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 21 May 2013 22:31:29 -0700 Subject: [PATCH] make model change events opt-in per repository --- NzbDrone.Core/Datastore/BasicRepository.cs | 11 +++++++++-- NzbDrone.Core/Instrumentation/LogRepository.cs | 5 ----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs index a2c07813a..18f6bf3b7 100644 --- a/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -194,10 +194,17 @@ namespace NzbDrone.Core.Datastore } - protected virtual void PublishModelEvent(TModel model, RepositoryAction action) + private void PublishModelEvent(TModel model, RepositoryAction action) { - _messageAggregator.PublishEvent(new ModelEvent(model, action)); + if (PublishModelEvents) + { + _messageAggregator.PublishEvent(new ModelEvent(model, action)); + } } + protected virtual bool PublishModelEvents + { + get { return false; } + } } } diff --git a/NzbDrone.Core/Instrumentation/LogRepository.cs b/NzbDrone.Core/Instrumentation/LogRepository.cs index 4858eaedd..abba443e8 100644 --- a/NzbDrone.Core/Instrumentation/LogRepository.cs +++ b/NzbDrone.Core/Instrumentation/LogRepository.cs @@ -23,10 +23,5 @@ 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