mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
Changed: Don't return unmapped folders on rootfolder API call. Massively improves loading time. (#3116)
This commit is contained in:
parent
95fdf38662
commit
623da76d16
@ -52,7 +52,7 @@ private int CreateRootFolder(RootFolderResource rootFolderResource)
|
|||||||
|
|
||||||
private List<RootFolderResource> GetRootFolders()
|
private List<RootFolderResource> GetRootFolders()
|
||||||
{
|
{
|
||||||
return _rootFolderService.AllWithUnmappedFolders().ToResource();
|
return _rootFolderService.AllWithSpace().ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteFolder(int id)
|
private void DeleteFolder(int id)
|
||||||
|
@ -15,6 +15,7 @@ public interface IRootFolderService
|
|||||||
{
|
{
|
||||||
List<RootFolder> All();
|
List<RootFolder> All();
|
||||||
List<RootFolder> AllWithUnmappedFolders();
|
List<RootFolder> AllWithUnmappedFolders();
|
||||||
|
List<RootFolder> AllWithSpace();
|
||||||
RootFolder Add(RootFolder rootDir);
|
RootFolder Add(RootFolder rootDir);
|
||||||
void Remove(int id);
|
void Remove(int id);
|
||||||
RootFolder Get(int id);
|
RootFolder Get(int id);
|
||||||
@ -62,6 +63,31 @@ public List<RootFolder> All()
|
|||||||
return rootFolders;
|
return rootFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RootFolder> AllWithSpace()
|
||||||
|
{
|
||||||
|
var rootFolders = _rootFolderRepository.All().ToList();
|
||||||
|
|
||||||
|
rootFolders.ForEach(folder =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (folder.Path.IsPathValid() && _diskProvider.FolderExists(folder.Path))
|
||||||
|
{
|
||||||
|
folder.FreeSpace = _diskProvider.GetAvailableSpace(folder.Path);
|
||||||
|
folder.TotalSpace = _diskProvider.GetTotalSize(folder.Path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//We don't want an exception to prevent the root folders from loading in the UI, so they can still be deleted
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
folder.FreeSpace = 0;
|
||||||
|
_logger.Error(ex, "Unable to get free space for root folder {0}", folder.Path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootFolders;
|
||||||
|
}
|
||||||
|
|
||||||
public List<RootFolder> AllWithUnmappedFolders()
|
public List<RootFolder> AllWithUnmappedFolders()
|
||||||
{
|
{
|
||||||
var rootFolders = _rootFolderRepository.All().ToList();
|
var rootFolders = _rootFolderRepository.All().ToList();
|
||||||
|
Loading…
Reference in New Issue
Block a user