Backup API improvements

This commit is contained in:
Mark McDowall 2017-08-20 23:26:37 -07:00
parent fa34af8f15
commit f3bf50e8d7
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
4 changed files with 17 additions and 6 deletions

View File

@ -21,9 +21,9 @@ namespace NzbDrone.Api.System.Backup
return backups.Select(b => new BackupResource
{
Id = b.Path.GetHashCode(),
Name = Path.GetFileName(b.Path),
Path = b.Path,
Id = b.Name.GetHashCode(),
Name = b.Name,
Path = $"/backup/{b.Type.ToString().ToLower()}/{b.Name}",
Type = b.Type,
Time = b.Time
}).ToList();

View File

@ -4,7 +4,7 @@ namespace NzbDrone.Core.Backup
{
public class Backup
{
public string Path { get; set; }
public string Name { get; set; }
public BackupType Type { get; set; }
public DateTime Time { get; set; }
}

View File

@ -4,7 +4,18 @@ namespace NzbDrone.Core.Backup
{
public class BackupCommand : Command
{
public BackupType Type { get; set; }
public BackupType Type
{
get
{
if (Trigger == CommandTrigger.Scheduled)
{
return BackupType.Scheduled;
}
return BackupType.Manual;
}
}
public override bool SendUpdatesToClient => true;

View File

@ -93,7 +93,7 @@ namespace NzbDrone.Core.Backup
{
backups.AddRange(GetBackupFiles(folder).Select(b => new Backup
{
Path = Path.GetFileName(b),
Name = Path.GetFileName(b),
Type = backupType,
Time = _diskProvider.FileGetLastWrite(b)
}));