mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
Add timeout parameter to root folder endpoint
Closes #1468 Closes #1556
This commit is contained in:
parent
1191371bc7
commit
af1e2fe2eb
2 changed files with 12 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
using Lidarr.Http.REST.Attributes;
|
using Lidarr.Http.REST.Attributes;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -56,7 +57,9 @@ namespace Lidarr.Api.V1.RootFolders
|
||||||
|
|
||||||
public override RootFolderResource GetResourceById(int id)
|
public override RootFolderResource GetResourceById(int id)
|
||||||
{
|
{
|
||||||
return _rootFolderService.Get(id).ToResource();
|
var timeout = Request?.GetBooleanQueryParameter("timeout", true) ?? true;
|
||||||
|
|
||||||
|
return _rootFolderService.Get(id, timeout).ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RestPostById]
|
[RestPostById]
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
RootFolder Add(RootFolder rootFolder);
|
RootFolder Add(RootFolder rootFolder);
|
||||||
RootFolder Update(RootFolder rootFolder);
|
RootFolder Update(RootFolder rootFolder);
|
||||||
void Remove(int id);
|
void Remove(int id);
|
||||||
RootFolder Get(int id);
|
RootFolder Get(int id, bool timeout);
|
||||||
List<RootFolder> AllForTag(int tagId);
|
List<RootFolder> AllForTag(int tagId);
|
||||||
RootFolder GetBestRootFolder(string path);
|
RootFolder GetBestRootFolder(string path);
|
||||||
string GetBestRootFolderPath(string path);
|
string GetBestRootFolderPath(string path);
|
||||||
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
{
|
{
|
||||||
if (folder.Path.IsPathValid(PathValidationType.CurrentOs))
|
if (folder.Path.IsPathValid(PathValidationType.CurrentOs))
|
||||||
{
|
{
|
||||||
GetDetails(folder);
|
GetDetails(folder, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
|
|
||||||
_commandQueueManager.Push(new RescanFoldersCommand(new List<string> { rootFolder.Path }, FilterFilesType.None, true, null));
|
_commandQueueManager.Push(new RescanFoldersCommand(new List<string> { rootFolder.Path }, FilterFilesType.None, true, null));
|
||||||
|
|
||||||
GetDetails(rootFolder);
|
GetDetails(rootFolder, true);
|
||||||
|
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
|
|
||||||
_rootFolderRepository.Update(rootFolder);
|
_rootFolderRepository.Update(rootFolder);
|
||||||
|
|
||||||
GetDetails(rootFolder);
|
GetDetails(rootFolder, true);
|
||||||
|
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
|
@ -127,10 +127,10 @@ namespace NzbDrone.Core.RootFolders
|
||||||
_rootFolderRepository.Delete(id);
|
_rootFolderRepository.Delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RootFolder Get(int id)
|
public RootFolder Get(int id, bool timeout)
|
||||||
{
|
{
|
||||||
var rootFolder = _rootFolderRepository.Get(id);
|
var rootFolder = _rootFolderRepository.Get(id);
|
||||||
GetDetails(rootFolder);
|
GetDetails(rootFolder, timeout);
|
||||||
|
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
return possibleRootFolder?.Path;
|
return possibleRootFolder?.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetDetails(RootFolder rootFolder)
|
private void GetDetails(RootFolder rootFolder, bool timeout)
|
||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
@ -170,7 +170,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
||||||
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
||||||
}
|
}
|
||||||
}).Wait(5000);
|
}).Wait(timeout ? 5000 : -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue