mirror of https://github.com/Sonarr/Sonarr
FreeSpace check now uses the root of the drive\share as the check
This commit is contained in:
parent
c8d43accfb
commit
470182e397
|
@ -294,13 +294,14 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
Ensure.That(() => path).IsValidPath();
|
Ensure.That(() => path).IsValidPath();
|
||||||
|
|
||||||
if (!FolderExists(path))
|
var root = GetPathRoot(path);
|
||||||
throw new DirectoryNotFoundException(path);
|
|
||||||
|
|
||||||
|
if (!FolderExists(root))
|
||||||
|
throw new DirectoryNotFoundException(root);
|
||||||
|
|
||||||
if (OsInfo.IsLinux)
|
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)
|
if (driveInfo == null)
|
||||||
{
|
{
|
||||||
|
@ -310,7 +311,7 @@ namespace NzbDrone.Common
|
||||||
return driveInfo.AvailableFreeSpace;
|
return driveInfo.AvailableFreeSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DriveFreeSpaceEx(path);
|
return DriveFreeSpaceEx(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long DriveFreeSpaceEx(string folderName)
|
private static long DriveFreeSpaceEx(string folderName)
|
||||||
|
|
|
@ -54,7 +54,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore]
|
|
||||||
public void should_reject_when_there_isnt_enough_disk_space()
|
public void should_reject_when_there_isnt_enough_disk_space()
|
||||||
{
|
{
|
||||||
GivenFileSize(100.Megabytes());
|
GivenFileSize(100.Megabytes());
|
||||||
|
@ -65,7 +64,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore]
|
|
||||||
public void should_reject_when_there_isnt_enough_space_for_file_plus_100mb_padding()
|
public void should_reject_when_there_isnt_enough_space_for_file_plus_100mb_padding()
|
||||||
{
|
{
|
||||||
GivenFileSize(100.Megabytes());
|
GivenFileSize(100.Megabytes());
|
||||||
|
@ -76,7 +74,6 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore]
|
|
||||||
public void should_accept_when_there_is_enough_disk_space()
|
public void should_accept_when_there_is_enough_disk_space()
|
||||||
{
|
{
|
||||||
GivenFileSize(100.Megabytes());
|
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()));
|
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
|
public class FreeSpaceSpecification : IImportDecisionEngineSpecification
|
||||||
{
|
{
|
||||||
private readonly IBuildFileNames _buildFileNames;
|
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public FreeSpaceSpecification(IBuildFileNames buildFileNames, IDiskProvider diskProvider, Logger logger)
|
public FreeSpaceSpecification(IDiskProvider diskProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_buildFileNames = buildFileNames;
|
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
@ -24,13 +22,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
||||||
{
|
{
|
||||||
//TODO: fix issues with this, seems to be completely broken...
|
var freeSpace = _diskProvider.GetAvilableSpace(localEpisode.Series.Path);
|
||||||
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);
|
|
||||||
|
|
||||||
if (freeSpace < localEpisode.Size + 100.Megabytes())
|
if (freeSpace < localEpisode.Size + 100.Megabytes())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue