FreeSpace check now uses the root of the drive\share as the check

pull/27/head^2
Mark McDowall 11 years ago
parent c8d43accfb
commit 470182e397

@ -294,13 +294,14 @@ namespace NzbDrone.Common
{
Ensure.That(() => path).IsValidPath();
if (!FolderExists(path))
throw new DirectoryNotFoundException(path);
var root = GetPathRoot(path);
if (!FolderExists(root))
throw new DirectoryNotFoundException(root);
if (OsInfo.IsLinux)
{
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && c.Name.Equals(Path.GetPathRoot(path), StringComparison.CurrentCultureIgnoreCase));
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && c.Name.Equals(root, StringComparison.CurrentCultureIgnoreCase));
if (driveInfo == null)
{
@ -310,7 +311,7 @@ namespace NzbDrone.Common
return driveInfo.AvailableFreeSpace;
}
return DriveFreeSpaceEx(path);
return DriveFreeSpaceEx(root);
}
private static long DriveFreeSpaceEx(string folderName)

@ -54,7 +54,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
}
[Test]
[Ignore]
public void should_reject_when_there_isnt_enough_disk_space()
{
GivenFileSize(100.Megabytes());
@ -65,7 +64,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
}
[Test]
[Ignore]
public void should_reject_when_there_isnt_enough_space_for_file_plus_100mb_padding()
{
GivenFileSize(100.Megabytes());
@ -76,7 +74,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
}
[Test]
[Ignore]
public void should_accept_when_there_is_enough_disk_space()
{
GivenFileSize(100.Megabytes());

@ -31,5 +31,12 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
{
Assert.Throws<DirectoryNotFoundException>(() => Subject.GetAvilableSpace(@"Z:\NOT_A_REAL_PATH\DOES_NOT_EXIST".AsOsAgnostic()));
}
[Test]
public void should_be_able_to_get_space_on_folder_that_doesnt_exist()
{
var result = Subject.GetAvilableSpace(@"C:\I_DO_NOT_EXIST".AsOsAgnostic());
result.Should().BeGreaterThan(0);
}
}
}

@ -9,13 +9,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
{
public class FreeSpaceSpecification : IImportDecisionEngineSpecification
{
private readonly IBuildFileNames _buildFileNames;
private readonly IDiskProvider _diskProvider;
private readonly Logger _logger;
public FreeSpaceSpecification(IBuildFileNames buildFileNames, IDiskProvider diskProvider, Logger logger)
public FreeSpaceSpecification(IDiskProvider diskProvider, Logger logger)
{
_buildFileNames = buildFileNames;
_diskProvider = diskProvider;
_logger = logger;
}
@ -23,14 +21,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
public string RejectionReason { get { return "Not enough free space"; } }
public bool IsSatisfiedBy(LocalEpisode localEpisode)
{
//TODO: fix issues with this, seems to be completely broken...
return true;
var newFileName = Path.GetFileNameWithoutExtension(localEpisode.Path);
var destinationFilename = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(localEpisode.Path));
var freeSpace = _diskProvider.GetAvilableSpace(destinationFilename);
{
var freeSpace = _diskProvider.GetAvilableSpace(localEpisode.Series.Path);
if (freeSpace < localEpisode.Size + 100.Megabytes())
{

Loading…
Cancel
Save