Added: Include total space with root folders

Closes #2468
pull/2/head
Leonardo Galli 7 years ago
parent 33cc228ac1
commit 032fc68892

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.RootFolders;
@ -9,6 +9,7 @@ namespace NzbDrone.Api.RootFolders
{ {
public string Path { get; set; } public string Path { get; set; }
public long? FreeSpace { get; set; } public long? FreeSpace { get; set; }
public long? TotalSpace { get; set; }
public List<UnmappedFolder> UnmappedFolders { get; set; } public List<UnmappedFolder> UnmappedFolders { get; set; }
} }
@ -25,6 +26,7 @@ namespace NzbDrone.Api.RootFolders
Path = model.Path, Path = model.Path,
FreeSpace = model.FreeSpace, FreeSpace = model.FreeSpace,
TotalSpace = model.TotalSpace,
UnmappedFolders = model.UnmappedFolders UnmappedFolders = model.UnmappedFolders
}; };
} }

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data; using Marr.Data;
using Marr.Data.Mapping; using Marr.Data.Mapping;
@ -87,7 +87,11 @@ namespace NzbDrone.Core.Datastore
RegisterMappers(); RegisterMappers();
Mapper.Entity<Config>().RegisterModel("Config"); 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<ScheduledTask>().RegisterModel("ScheduledTasks");
Mapper.Entity<IndexerDefinition>().RegisterDefinition("Indexers") Mapper.Entity<IndexerDefinition>().RegisterDefinition("Indexers")

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
@ -9,6 +9,7 @@ namespace NzbDrone.Core.RootFolders
public string Path { get; set; } public string Path { get; set; }
public long? FreeSpace { get; set; } public long? FreeSpace { get; set; }
public long? TotalSpace { get; set; }
public List<UnmappedFolder> UnmappedFolders { get; set; } public List<UnmappedFolder> UnmappedFolders { get; set; }
} }

@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -76,14 +76,15 @@ namespace NzbDrone.Core.RootFolders
if (folder.Path.IsPathValid() && _diskProvider.FolderExists(folder.Path)) if (folder.Path.IsPathValid() && _diskProvider.FolderExists(folder.Path))
{ {
folder.FreeSpace = _diskProvider.GetAvailableSpace(folder.Path); folder.FreeSpace = _diskProvider.GetAvailableSpace(folder.Path);
folder.TotalSpace = _diskProvider.GetTotalSize(folder.Path);
folder.UnmappedFolders = GetUnmappedFolders(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 //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) catch (Exception ex)
{ {
_logger.Error(ex, "Unable to get free space and unmapped folders for root folder: " + folder.Path);
folder.FreeSpace = 0; 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>(); folder.UnmappedFolders = new List<UnmappedFolder>();
} }
}); });
@ -211,6 +212,7 @@ namespace NzbDrone.Core.RootFolders
{ {
var rootFolder = _rootFolderRepository.Get(id); var rootFolder = _rootFolderRepository.Get(id);
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path); rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path); rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
return rootFolder; return rootFolder;
} }

Loading…
Cancel
Save