mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 07:12:40 +00: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 FluentValidation;
|
||||
using Lidarr.Http;
|
||||
using Lidarr.Http.Extensions;
|
||||
using Lidarr.Http.REST;
|
||||
using Lidarr.Http.REST.Attributes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -56,7 +57,9 @@ public RootFolderController(IRootFolderService rootFolderService,
|
|||
|
||||
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]
|
||||
|
|
|
@ -20,7 +20,7 @@ public interface IRootFolderService
|
|||
RootFolder Add(RootFolder rootFolder);
|
||||
RootFolder Update(RootFolder rootFolder);
|
||||
void Remove(int id);
|
||||
RootFolder Get(int id);
|
||||
RootFolder Get(int id, bool timeout);
|
||||
List<RootFolder> AllForTag(int tagId);
|
||||
RootFolder GetBestRootFolder(string path);
|
||||
string GetBestRootFolderPath(string path);
|
||||
|
@ -61,7 +61,7 @@ public List<RootFolder> AllWithSpaceStats()
|
|||
{
|
||||
if (folder.Path.IsPathValid(PathValidationType.CurrentOs))
|
||||
{
|
||||
GetDetails(folder);
|
||||
GetDetails(folder, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public RootFolder Add(RootFolder rootFolder)
|
|||
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(new List<string> { rootFolder.Path }, FilterFilesType.None, true, null));
|
||||
|
||||
GetDetails(rootFolder);
|
||||
GetDetails(rootFolder, true);
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public RootFolder Update(RootFolder rootFolder)
|
|||
|
||||
_rootFolderRepository.Update(rootFolder);
|
||||
|
||||
GetDetails(rootFolder);
|
||||
GetDetails(rootFolder, true);
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ public void Remove(int id)
|
|||
_rootFolderRepository.Delete(id);
|
||||
}
|
||||
|
||||
public RootFolder Get(int id)
|
||||
public RootFolder Get(int id, bool timeout)
|
||||
{
|
||||
var rootFolder = _rootFolderRepository.Get(id);
|
||||
GetDetails(rootFolder);
|
||||
GetDetails(rootFolder, timeout);
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public string GetBestRootFolderPath(string path)
|
|||
return possibleRootFolder?.Path;
|
||||
}
|
||||
|
||||
private void GetDetails(RootFolder rootFolder)
|
||||
private void GetDetails(RootFolder rootFolder, bool timeout)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ private void GetDetails(RootFolder rootFolder)
|
|||
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
||||
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
||||
}
|
||||
}).Wait(5000);
|
||||
}).Wait(timeout ? 5000 : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue