You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
41 lines
1.4 KiB
using NzbDrone.Common.Disk;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Configuration;
|
|
using NzbDrone.Core.Localization;
|
|
using NzbDrone.Core.MediaFiles.Events;
|
|
|
|
namespace NzbDrone.Core.HealthCheck.Checks
|
|
{
|
|
[CheckOn(typeof(TrackImportedEvent), CheckOnCondition.FailedOnly)]
|
|
[CheckOn(typeof(TrackImportFailedEvent), CheckOnCondition.SuccessfulOnly)]
|
|
public class RecyclingBinCheck : HealthCheckBase
|
|
{
|
|
private readonly IConfigService _configService;
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
public RecyclingBinCheck(IConfigService configService, IDiskProvider diskProvider, ILocalizationService localizationService)
|
|
: base(localizationService)
|
|
{
|
|
_configService = configService;
|
|
_diskProvider = diskProvider;
|
|
}
|
|
|
|
public override HealthCheck Check()
|
|
{
|
|
var recycleBin = _configService.RecycleBin;
|
|
|
|
if (recycleBin.IsNullOrWhiteSpace())
|
|
{
|
|
return new HealthCheck(GetType());
|
|
}
|
|
|
|
if (!_diskProvider.FolderWritable(recycleBin))
|
|
{
|
|
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RecycleBinUnableToWriteHealthCheck"), recycleBin), "#cannot-write-recycle-bin");
|
|
}
|
|
|
|
return new HealthCheck(GetType());
|
|
}
|
|
}
|
|
}
|