@ -13,7 +13,7 @@ namespace NzbDrone.Core.RootFolders
{
List < RootFolder > All ( ) ;
RootFolder Add ( RootFolder rootDir ) ;
void Remove ( int rootDirId ) ;
void Remove ( long rootDirId ) ;
List < String > GetUnmappedFolders ( string path ) ;
Dictionary < string , ulong > FreeSpaceOnDrives ( ) ;
}
@ -34,28 +34,36 @@ namespace NzbDrone.Core.RootFolders
public virtual List < RootFolder > All ( )
{
return _rootFolderRepository . All ( ) ;
var rootFolders = _rootFolderRepository . All ( ) ;
rootFolders . ForEach ( folder = >
{
folder . FreeSpace = _diskProvider . FreeDiskSpace ( new DirectoryInfo ( folder . Path ) ) ;
folder . UnmappedFolders = GetUnmappedFolders ( folder . Path ) ;
} ) ;
return rootFolders ;
}
public virtual RootFolder Add ( RootFolder rootDir )
public virtual RootFolder Add ( RootFolder root Folde r)
{
if ( String . IsNullOrWhiteSpace ( rootDir . Path ) | | ! Path . IsPathRooted ( rootDir . Path ) )
if ( String . IsNullOrWhiteSpace ( root Folde r. Path ) | | ! Path . IsPathRooted ( root Folde r. Path ) )
throw new ArgumentException ( "Invalid path" ) ;
if ( ! _diskProvider . FolderExists ( rootDir . Path ) )
if ( ! _diskProvider . FolderExists ( root Folde r. Path ) )
throw new DirectoryNotFoundException ( "Can't add root directory that doesn't exist." ) ;
if ( All ( ) . Exists ( r = > DiskProvider . PathEquals ( r . Path , root Di r. Path ) ) )
if ( All ( ) . Exists ( r = > DiskProvider . PathEquals ( r . Path , root Folde r. Path ) ) )
throw new InvalidOperationException ( "Root directory already exist." ) ;
_rootFolderRepository . Add ( root Di r) ;
_rootFolderRepository . Add ( root Folde r) ;
root Di r. FreeSpace = _diskProvider . FreeDiskSpace ( new DirectoryInfo ( root Di r. Path ) ) ;
root Dir. UnmappedFolders = GetUnmappedFolders ( rootDi r. Path ) ;
return root Di r;
root Folde r. FreeSpace = _diskProvider . FreeDiskSpace ( new DirectoryInfo ( root Folde r. Path ) ) ;
root Folder. UnmappedFolders = GetUnmappedFolders ( rootFolde r. Path ) ;
return root Folde r;
}
public virtual void Remove ( int rootDirId )
public virtual void Remove ( long rootDirId )
{
_rootFolderRepository . Delete ( rootDirId ) ;
}
@ -86,7 +94,6 @@ namespace NzbDrone.Core.RootFolders
return results ;
}
public virtual Dictionary < string , ulong > FreeSpaceOnDrives ( )
{
var freeSpace = new Dictionary < string , ulong > ( ) ;