|
|
@ -1,11 +1,13 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Housekeeping
|
|
|
|
namespace NzbDrone.Core.Housekeeping
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class HousekeepingService : IExecute<HousekeepingCommand>
|
|
|
|
public class HousekeepingService : IExecute<HousekeepingCommand>, IHandleAsync<ApplicationStartedEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IEnumerable<IHousekeepingTask> _housekeepers;
|
|
|
|
private readonly IEnumerable<IHousekeepingTask> _housekeepers;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
@ -16,7 +18,7 @@ namespace NzbDrone.Core.Housekeeping
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(HousekeepingCommand message)
|
|
|
|
private void Clean()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Info("Running housecleaning tasks");
|
|
|
|
_logger.Info("Running housecleaning tasks");
|
|
|
|
|
|
|
|
|
|
|
@ -32,5 +34,15 @@ namespace NzbDrone.Core.Housekeeping
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(HousekeepingCommand message)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Clean();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(ApplicationStartedEvent message)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Clean();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|