mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
Added commands to delete logs and log files (separately)
This commit is contained in:
parent
e152ecc55d
commit
1274c1c144
12 changed files with 191 additions and 28 deletions
40
NzbDrone.Core/Instrumentation/DeleteLogFilesService.cs
Normal file
40
NzbDrone.Core/Instrumentation/DeleteLogFilesService.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Instrumentation.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public interface IDeleteLogFilesService
|
||||
{
|
||||
}
|
||||
|
||||
public class DeleteLogFilesService : IDeleteLogFilesService, IExecute<DeleteLogFilesCommand>
|
||||
{
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DeleteLogFilesService(IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, Logger logger)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_appFolderInfo = appFolderInfo;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Execute(DeleteLogFilesCommand message)
|
||||
{
|
||||
var logFiles = _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), SearchOption.TopDirectoryOnly);
|
||||
|
||||
foreach (var logFile in logFiles)
|
||||
{
|
||||
_diskProvider.DeleteFile(logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue