mirror of
https://github.com/Radarr/Radarr
synced 2025-02-21 22:07:21 +00:00
parent
33cc228ac1
commit
032fc68892
4 changed files with 18 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
|
@ -9,6 +9,7 @@ public class RootFolderResource : RestResource
|
|||
{
|
||||
public string Path { get; set; }
|
||||
public long? FreeSpace { get; set; }
|
||||
public long? TotalSpace { get; set; }
|
||||
|
||||
public List<UnmappedFolder> UnmappedFolders { get; set; }
|
||||
}
|
||||
|
@ -25,6 +26,7 @@ public static RootFolderResource ToResource(this RootFolder model)
|
|||
|
||||
Path = model.Path,
|
||||
FreeSpace = model.FreeSpace,
|
||||
TotalSpace = model.TotalSpace,
|
||||
UnmappedFolders = model.UnmappedFolders
|
||||
};
|
||||
}
|
||||
|
@ -48,4 +50,4 @@ public static List<RootFolderResource> ToResource(this IEnumerable<RootFolder> m
|
|||
return models.Select(ToResource).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Marr.Data;
|
||||
using Marr.Data.Mapping;
|
||||
|
@ -87,7 +87,11 @@ public static void Map()
|
|||
RegisterMappers();
|
||||
|
||||
Mapper.Entity<Config>().RegisterModel("Config");
|
||||
Mapper.Entity<RootFolder>().RegisterModel("RootFolders").Ignore(r => r.FreeSpace);
|
||||
|
||||
Mapper.Entity<RootFolder>().RegisterModel("RootFolders")
|
||||
.Ignore(r => r.FreeSpace)
|
||||
.Ignore(r => r.TotalSpace);
|
||||
|
||||
Mapper.Entity<ScheduledTask>().RegisterModel("ScheduledTasks");
|
||||
|
||||
Mapper.Entity<IndexerDefinition>().RegisterDefinition("Indexers")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
|
||||
|
@ -9,7 +9,8 @@ public class RootFolder : ModelBase
|
|||
public string Path { get; set; }
|
||||
|
||||
public long? FreeSpace { get; set; }
|
||||
public long? TotalSpace { get; set; }
|
||||
|
||||
public List<UnmappedFolder> UnmappedFolders { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -76,14 +76,15 @@ public List<RootFolder> AllWithUnmappedFolders()
|
|||
if (folder.Path.IsPathValid() && _diskProvider.FolderExists(folder.Path))
|
||||
{
|
||||
folder.FreeSpace = _diskProvider.GetAvailableSpace(folder.Path);
|
||||
folder.TotalSpace = _diskProvider.GetTotalSize(folder.Path);
|
||||
folder.UnmappedFolders = GetUnmappedFolders(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)
|
||||
{
|
||||
_logger.Error(ex, "Unable to get free space and unmapped folders for root folder: " + folder.Path);
|
||||
folder.FreeSpace = 0;
|
||||
_logger.Error(ex, "Unable to get free space and unmapped folders for root folder {0}", folder.Path);
|
||||
folder.UnmappedFolders = new List<UnmappedFolder>();
|
||||
}
|
||||
});
|
||||
|
@ -211,8 +212,9 @@ public RootFolder Get(int id)
|
|||
{
|
||||
var rootFolder = _rootFolderRepository.Get(id);
|
||||
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
||||
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
||||
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
|
||||
return rootFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue