1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-17 21:26:13 -04:00
Files
Sonarr/src/Sonarr.Http/Frontend/Mappers/BackupFileMapper.cs
2026-03-16 13:48:38 -07:00

33 lines
978 B
C#

using System.IO;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Backup;
namespace Sonarr.Http.Frontend.Mappers
{
public class BackupFileMapper : StaticResourceMapperBase
{
private readonly IBackupService _backupService;
public BackupFileMapper(IBackupService backupService, IDiskProvider diskProvider, Logger logger)
: base(diskProvider, logger)
{
_backupService = backupService;
}
protected override string FolderPath => _backupService.GetBackupFolder();
protected override string MapPath(string resourceUrl)
{
var path = resourceUrl.Replace("/backup/", "").Replace('/', Path.DirectorySeparatorChar);
return Path.Combine(FolderPath, path);
}
public override bool CanHandle(string resourceUrl)
{
return resourceUrl.StartsWith("/backup/") && BackupService.BackupFileRegex.IsMatch(resourceUrl);
}
}
}