Calculate storage based on root drive

dashboard
Pat Hartl 2023-01-16 00:48:51 -06:00
parent 55f47f7f26
commit ddc582b8e7
1 changed files with 3 additions and 3 deletions

View File

@ -23,11 +23,11 @@ namespace LANCommander.Controllers
public IActionResult Index()
{
var drives = DriveInfo.GetDrives();
var root = Path.GetPathRoot(System.Reflection.Assembly.GetExecutingAssembly().Location);
var model = new DashboardViewModel();
model.TotalStorageSize = ByteSize.FromBytes(drives.Where(d => d.IsReady).Sum(d => d.TotalSize));
model.TotalAvailableFreeSpace = ByteSize.FromBytes(drives.Where(d => d.IsReady).Sum(d => d.AvailableFreeSpace));
model.TotalStorageSize = ByteSize.FromBytes(drives.Where(d => d.IsReady && d.Name == root).Sum(d => d.TotalSize));
model.TotalAvailableFreeSpace = ByteSize.FromBytes(drives.Where(d => d.IsReady && d.Name == root).Sum(d => d.AvailableFreeSpace));
model.TotalUploadDirectorySize = ByteSize.FromBytes(new DirectoryInfo("Upload").EnumerateFiles().Sum(f => f.Length));
using (Repository<Game> repo = new Repository<Game>(Context, HttpContext))