mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using NzbDrone.Core.Backup;
|
|
using Lidarr.Http;
|
|
|
|
namespace Lidarr.Api.V3.System.Backup
|
|
{
|
|
public class BackupModule : LidarrRestModule<BackupResource>
|
|
{
|
|
private readonly IBackupService _backupService;
|
|
|
|
public BackupModule(IBackupService backupService) : base("system/backup")
|
|
{
|
|
_backupService = backupService;
|
|
GetResourceAll = GetBackupFiles;
|
|
}
|
|
|
|
public List<BackupResource> GetBackupFiles()
|
|
{
|
|
var backups = _backupService.GetBackups();
|
|
|
|
return backups.Select(b => new BackupResource
|
|
{
|
|
Id = b.Name.GetHashCode(),
|
|
Name = b.Name,
|
|
Path = $"/backup/{b.Type.ToString().ToLower()}/{b.Name}",
|
|
Type = b.Type,
|
|
Time = b.Time
|
|
})
|
|
.OrderByDescending(b => b.Time)
|
|
.ToList();
|
|
}
|
|
}
|
|
}
|