mirror of
https://github.com/Radarr/Radarr
synced 2024-12-23 08:22:39 +00: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
2 changed files with 27 additions and 1 deletions
|
@ -52,7 +52,7 @@ private int CreateRootFolder(RootFolderResource rootFolderResource)
|
|||
|
||||
private List<RootFolderResource> GetRootFolders()
|
||||
{
|
||||
return _rootFolderService.AllWithUnmappedFolders().ToResource();
|
||||
return _rootFolderService.AllWithSpace().ToResource();
|
||||
}
|
||||
|
||||
private void DeleteFolder(int id)
|
||||
|
|
|
@ -15,6 +15,7 @@ public interface IRootFolderService
|
|||
{
|
||||
List<RootFolder> All();
|
||||
List<RootFolder> AllWithUnmappedFolders();
|
||||
List<RootFolder> AllWithSpace();
|
||||
RootFolder Add(RootFolder rootDir);
|
||||
void Remove(int id);
|
||||
RootFolder Get(int id);
|
||||
|
@ -62,6 +63,31 @@ public List<RootFolder> All()
|
|||
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()
|
||||
{
|
||||
var rootFolders = _rootFolderRepository.All().ToList();
|
||||
|
|
Loading…
Reference in a new issue