New: User configurable minimum free disk space

Closes #3233
This commit is contained in:
Ken Murphy 2019-08-15 01:14:59 -04:00 committed by Mark McDowall
parent b2267a55ce
commit 7829b18b3c
7 changed files with 33 additions and 2 deletions

View File

@ -165,6 +165,23 @@ class MediaManagement extends Component {
</FormGroup>
}
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
size={sizes.MEDIUM}
>
<FormLabel>Minimum Free Space</FormLabel>
<FormInputGroup
type={inputTypes.NUMBER}
unit='MB'
name="minimumFreeSpaceWhenImporting"
helpText="Prevent import if it would leave less than this amount of disk space available"
onChange={onInputChange}
{...settings.minimumFreeSpaceWhenImporting}
/>
</FormGroup>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}

View File

@ -68,8 +68,11 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
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_min_free_space()
{
Mocker.GetMock<IConfigService>()
.Setup(s => s.MinimumFreeSpaceWhenImporting)
.Returns(100);
GivenFileSize(100.Megabytes());
GivenFreeSpace(150.Megabytes());

View File

@ -196,6 +196,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("SkipFreeSpaceCheckWhenImporting", value); }
}
public int MinimumFreeSpaceWhenImporting
{
get { return GetValueInt("MinimumFreeSpaceWhenImporting", 100); }
set { SetValue("MinimumFreeSpaceWhenImporting", value); }
}
public bool CopyUsingHardlinks
{
get { return GetValueBoolean("CopyUsingHardlinks", true); }

View File

@ -33,6 +33,7 @@ namespace NzbDrone.Core.Configuration
bool DeleteEmptyFolders { get; set; }
FileDateType FileDate { get; set; }
bool SkipFreeSpaceCheckWhenImporting { get; set; }
int MinimumFreeSpaceWhenImporting { get; set; }
bool CopyUsingHardlinks { get; set; }
bool EnableMediaInfo { get; set; }
bool ImportExtraFiles { get; set; }

View File

@ -47,7 +47,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
return Decision.Accept();
}
if (freeSpace < localEpisode.Size + 100.Megabytes())
if (freeSpace < localEpisode.Size + _configService.MinimumFreeSpaceWhenImporting.Megabytes())
{
_logger.Warn("Not enough free space ({0}) to import: {1} ({2})", freeSpace, localEpisode, localEpisode.Size);
return Decision.Reject("Not enough free space");

View File

@ -13,6 +13,7 @@ namespace Sonarr.Api.V3.Config
SharedValidator.RuleFor(c => c.FileChmod).NotEmpty();
SharedValidator.RuleFor(c => c.FolderChmod).NotEmpty();
SharedValidator.RuleFor(c => c.RecycleBin).IsValidPath().SetValidator(pathExistsValidator).When(c => !string.IsNullOrWhiteSpace(c.RecycleBin));
SharedValidator.RuleFor(c => c.MinimumFreeSpaceWhenImporting).GreaterThanOrEqualTo(100);
}
protected override MediaManagementConfigResource ToResource(IConfigService model)

View File

@ -25,6 +25,7 @@ namespace Sonarr.Api.V3.Config
public EpisodeTitleRequiredType EpisodeTitleRequired { get; set; }
public bool SkipFreeSpaceCheckWhenImporting { get; set; }
public int MinimumFreeSpaceWhenImporting { get; set; }
public bool CopyUsingHardlinks { get; set; }
public bool ImportExtraFiles { get; set; }
public string ExtraFileExtensions { get; set; }
@ -54,6 +55,7 @@ namespace Sonarr.Api.V3.Config
EpisodeTitleRequired = model.EpisodeTitleRequired,
SkipFreeSpaceCheckWhenImporting = model.SkipFreeSpaceCheckWhenImporting,
MinimumFreeSpaceWhenImporting = model.MinimumFreeSpaceWhenImporting,
CopyUsingHardlinks = model.CopyUsingHardlinks,
ImportExtraFiles = model.ImportExtraFiles,
ExtraFileExtensions = model.ExtraFileExtensions,