mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-08 05:51:47 -07:00
New: User configurable minimum free disk space
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
d7f96fa139
commit
6529ddb22c
7 changed files with 34 additions and 2 deletions
|
@ -147,6 +147,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}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Lidarr.Api.V1.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)
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Lidarr.Api.V1.Config
|
|||
public string ChownGroup { 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; }
|
||||
|
@ -52,6 +53,7 @@ namespace Lidarr.Api.V1.Config
|
|||
ChownGroup = model.ChownGroup,
|
||||
|
||||
SkipFreeSpaceCheckWhenImporting = model.SkipFreeSpaceCheckWhenImporting,
|
||||
MinimumFreeSpaceWhenImporting = model.MinimumFreeSpaceWhenImporting,
|
||||
CopyUsingHardlinks = model.CopyUsingHardlinks,
|
||||
ImportExtraFiles = model.ImportExtraFiles,
|
||||
ExtraFileExtensions = model.ExtraFileExtensions,
|
||||
|
|
|
@ -66,8 +66,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.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());
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -32,6 +32,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 ImportExtraFiles { get; set; }
|
||||
string ExtraFileExtensions { get; set; }
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
|
|||
return Decision.Accept();
|
||||
}
|
||||
|
||||
if (freeSpace < localTrack.Size + 100.Megabytes())
|
||||
if (freeSpace < localTrack.Size + _configService.MinimumFreeSpaceWhenImporting.Megabytes())
|
||||
{
|
||||
_logger.Warn("Not enough free space ({0}) to import: {1} ({2})", freeSpace, localTrack, localTrack.Size);
|
||||
return Decision.Reject("Not enough free space");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue