New: Per download client setting to Remove Completed/Failed downloads instead of global setting
This commit is contained in:
parent
1400b96816
commit
5f197800fc
|
@ -16,4 +16,9 @@
|
||||||
color: #3a3f51;
|
color: #3a3f51;
|
||||||
font-size: 21px;
|
font-size: 21px;
|
||||||
line-height: inherit;
|
line-height: inherit;
|
||||||
|
|
||||||
|
&.small {
|
||||||
|
color: #909293;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { sizes } from 'Helpers/Props';
|
||||||
import styles from './FieldSet.css';
|
import styles from './FieldSet.css';
|
||||||
|
|
||||||
class FieldSet extends Component {
|
class FieldSet extends Component {
|
||||||
|
@ -9,13 +11,14 @@ class FieldSet extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
|
size,
|
||||||
legend,
|
legend,
|
||||||
children
|
children
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<fieldset className={styles.fieldSet}>
|
<fieldset className={styles.fieldSet}>
|
||||||
<legend className={styles.legend}>
|
<legend className={classNames(styles.legend, (size === sizes.SMALL) && styles.small)}>
|
||||||
{legend}
|
{legend}
|
||||||
</legend>
|
</legend>
|
||||||
{children}
|
{children}
|
||||||
|
@ -26,8 +29,13 @@ class FieldSet extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldSet.propTypes = {
|
FieldSet.propTypes = {
|
||||||
|
size: PropTypes.oneOf(sizes.all).isRequired,
|
||||||
legend: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
legend: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
||||||
children: PropTypes.node
|
children: PropTypes.node
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FieldSet.defaultProps = {
|
||||||
|
size: sizes.MEDIUM
|
||||||
|
};
|
||||||
|
|
||||||
export default FieldSet;
|
export default FieldSet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { inputTypes, kinds } from 'Helpers/Props';
|
import { inputTypes, kinds, sizes } from 'Helpers/Props';
|
||||||
import Alert from 'Components/Alert';
|
import Alert from 'Components/Alert';
|
||||||
import Button from 'Components/Link/Button';
|
import Button from 'Components/Link/Button';
|
||||||
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
||||||
|
@ -9,6 +9,7 @@ import ModalContent from 'Components/Modal/ModalContent';
|
||||||
import ModalHeader from 'Components/Modal/ModalHeader';
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||||
import ModalBody from 'Components/Modal/ModalBody';
|
import ModalBody from 'Components/Modal/ModalBody';
|
||||||
import ModalFooter from 'Components/Modal/ModalFooter';
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
||||||
|
import FieldSet from 'Components/FieldSet';
|
||||||
import Form from 'Components/Form/Form';
|
import Form from 'Components/Form/Form';
|
||||||
import FormGroup from 'Components/Form/FormGroup';
|
import FormGroup from 'Components/Form/FormGroup';
|
||||||
import FormLabel from 'Components/Form/FormLabel';
|
import FormLabel from 'Components/Form/FormLabel';
|
||||||
|
@ -44,7 +45,10 @@ class EditDownloadClientModalContent extends Component {
|
||||||
implementationName,
|
implementationName,
|
||||||
name,
|
name,
|
||||||
enable,
|
enable,
|
||||||
|
protocol,
|
||||||
priority,
|
priority,
|
||||||
|
removeCompletedDownloads,
|
||||||
|
removeFailedDownloads,
|
||||||
fields,
|
fields,
|
||||||
message
|
message
|
||||||
} = item;
|
} = item;
|
||||||
|
@ -133,6 +137,37 @@ class EditDownloadClientModalContent extends Component {
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
|
<FieldSet
|
||||||
|
size={sizes.SMALL}
|
||||||
|
legend="Completed Download Handling"
|
||||||
|
>
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Remove Completed</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.CHECK}
|
||||||
|
name="removeCompletedDownloads"
|
||||||
|
helpText="Remove imported downloads from download client history (when finished seeding for torrents)"
|
||||||
|
{...removeCompletedDownloads}
|
||||||
|
onChange={onInputChange}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
|
{
|
||||||
|
protocol.value !== 'torrent' &&
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Remove Failed</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.CHECK}
|
||||||
|
name="removeFailedDownloads"
|
||||||
|
helpText="Remove failed downloads from download client history"
|
||||||
|
{...removeFailedDownloads}
|
||||||
|
onChange={onInputChange}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
}
|
||||||
|
</FieldSet>
|
||||||
</Form>
|
</Form>
|
||||||
}
|
}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { inputTypes, sizes } from 'Helpers/Props';
|
import { inputTypes, kinds, sizes } from 'Helpers/Props';
|
||||||
|
import Alert from 'Components/Alert';
|
||||||
import FieldSet from 'Components/FieldSet';
|
import FieldSet from 'Components/FieldSet';
|
||||||
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||||
import Form from 'Components/Form/Form';
|
import Form from 'Components/Form/Form';
|
||||||
|
@ -31,11 +32,16 @@ function DownloadClientOptions(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
hasSettings && !isFetching && !error &&
|
hasSettings && !isFetching && !error && advancedSettings &&
|
||||||
<div>
|
<div>
|
||||||
<FieldSet legend="Completed Download Handling">
|
<FieldSet legend="Completed Download Handling">
|
||||||
|
|
||||||
<Form>
|
<Form>
|
||||||
<FormGroup size={sizes.MEDIUM}>
|
<FormGroup
|
||||||
|
advancedSettings={advancedSettings}
|
||||||
|
isAdvanced={true}
|
||||||
|
size={sizes.MEDIUM}
|
||||||
|
>
|
||||||
<FormLabel>Enable</FormLabel>
|
<FormLabel>Enable</FormLabel>
|
||||||
|
|
||||||
<FormInputGroup
|
<FormInputGroup
|
||||||
|
@ -52,25 +58,7 @@ function DownloadClientOptions(props) {
|
||||||
isAdvanced={true}
|
isAdvanced={true}
|
||||||
size={sizes.MEDIUM}
|
size={sizes.MEDIUM}
|
||||||
>
|
>
|
||||||
<FormLabel>Remove</FormLabel>
|
<FormLabel>Redownload Failed</FormLabel>
|
||||||
|
|
||||||
<FormInputGroup
|
|
||||||
type={inputTypes.CHECK}
|
|
||||||
name="removeCompletedDownloads"
|
|
||||||
helpText="Remove imported downloads from download client history"
|
|
||||||
onChange={onInputChange}
|
|
||||||
{...settings.removeCompletedDownloads}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
</Form>
|
|
||||||
</FieldSet>
|
|
||||||
|
|
||||||
<FieldSet
|
|
||||||
legend="Failed Download Handling"
|
|
||||||
>
|
|
||||||
<Form>
|
|
||||||
<FormGroup size={sizes.MEDIUM}>
|
|
||||||
<FormLabel>Redownload</FormLabel>
|
|
||||||
|
|
||||||
<FormInputGroup
|
<FormInputGroup
|
||||||
type={inputTypes.CHECK}
|
type={inputTypes.CHECK}
|
||||||
|
@ -80,23 +68,11 @@ function DownloadClientOptions(props) {
|
||||||
{...settings.autoRedownloadFailed}
|
{...settings.autoRedownloadFailed}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
<FormGroup
|
|
||||||
advancedSettings={advancedSettings}
|
|
||||||
isAdvanced={true}
|
|
||||||
size={sizes.MEDIUM}
|
|
||||||
>
|
|
||||||
<FormLabel>Remove</FormLabel>
|
|
||||||
|
|
||||||
<FormInputGroup
|
|
||||||
type={inputTypes.CHECK}
|
|
||||||
name="removeFailedDownloads"
|
|
||||||
helpText="Remove failed downloads from download client history"
|
|
||||||
onChange={onInputChange}
|
|
||||||
{...settings.removeFailedDownloads}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
|
<Alert kind={kinds.INFO}>
|
||||||
|
The Remove settings were moved to the individual Download Client settings in the table above.
|
||||||
|
</Alert>
|
||||||
</FieldSet>
|
</FieldSet>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,7 @@ namespace NzbDrone.Api.Config
|
||||||
public string DownloadClientWorkingFolders { get; set; }
|
public string DownloadClientWorkingFolders { get; set; }
|
||||||
|
|
||||||
public bool EnableCompletedDownloadHandling { get; set; }
|
public bool EnableCompletedDownloadHandling { get; set; }
|
||||||
public bool RemoveCompletedDownloads { get; set; }
|
|
||||||
|
|
||||||
public bool AutoRedownloadFailed { get; set; }
|
public bool AutoRedownloadFailed { get; set; }
|
||||||
public bool RemoveFailedDownloads { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DownloadClientConfigResourceMapper
|
public static class DownloadClientConfigResourceMapper
|
||||||
|
@ -23,10 +20,7 @@ namespace NzbDrone.Api.Config
|
||||||
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
|
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
|
||||||
|
|
||||||
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
|
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
|
||||||
RemoveCompletedDownloads = model.RemoveCompletedDownloads,
|
AutoRedownloadFailed = model.AutoRedownloadFailed
|
||||||
|
|
||||||
AutoRedownloadFailed = model.AutoRedownloadFailed,
|
|
||||||
RemoveFailedDownloads = model.RemoveFailedDownloads
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace NzbDrone.Api.DownloadClient
|
||||||
resource.Enable = definition.Enable;
|
resource.Enable = definition.Enable;
|
||||||
resource.Protocol = definition.Protocol;
|
resource.Protocol = definition.Protocol;
|
||||||
resource.Priority = definition.Priority;
|
resource.Priority = definition.Priority;
|
||||||
|
resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads;
|
||||||
|
resource.RemoveFailedDownloads = definition.RemoveFailedDownloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MapToModel(DownloadClientDefinition definition, DownloadClientResource resource)
|
protected override void MapToModel(DownloadClientDefinition definition, DownloadClientResource resource)
|
||||||
|
@ -25,6 +27,8 @@ namespace NzbDrone.Api.DownloadClient
|
||||||
definition.Enable = resource.Enable;
|
definition.Enable = resource.Enable;
|
||||||
definition.Protocol = resource.Protocol;
|
definition.Protocol = resource.Protocol;
|
||||||
definition.Priority = resource.Priority;
|
definition.Priority = resource.Priority;
|
||||||
|
definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads;
|
||||||
|
definition.RemoveFailedDownloads = resource.RemoveFailedDownloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
||||||
|
|
|
@ -7,5 +7,7 @@ namespace NzbDrone.Api.DownloadClient
|
||||||
public bool Enable { get; set; }
|
public bool Enable { get; set; }
|
||||||
public DownloadProtocol Protocol { get; set; }
|
public DownloadProtocol Protocol { get; set; }
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
public bool RemoveCompletedDownloads { get; set; }
|
||||||
|
public bool RemoveFailedDownloads { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
|
using NzbDrone.Core.Download.Clients.RTorrent;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class cdh_per_downloadclientFixture : MigrationTest<cdh_per_downloadclient>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_set_cdh_to_enabled()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("DownloadClients").Row(new
|
||||||
|
{
|
||||||
|
Enable = 1,
|
||||||
|
Name = "Deluge",
|
||||||
|
Implementation = "Deluge",
|
||||||
|
Priority = 1,
|
||||||
|
Settings = new DelugeSettings85
|
||||||
|
{
|
||||||
|
Host = "127.0.0.1",
|
||||||
|
TvCategory = "abc",
|
||||||
|
UrlBase = "/my/"
|
||||||
|
}.ToJson(),
|
||||||
|
ConfigContract = "DelugeSettings"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients");
|
||||||
|
|
||||||
|
items.Should().HaveCount(1);
|
||||||
|
items.First().RemoveCompletedDownloads.Should().BeTrue();
|
||||||
|
items.First().RemoveFailedDownloads.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_set_cdh_to_disabled_when_globally_disabled()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("Config").Row(new
|
||||||
|
{
|
||||||
|
Key = "removecompleteddownloads",
|
||||||
|
Value = "False"
|
||||||
|
});
|
||||||
|
|
||||||
|
c.Insert.IntoTable("DownloadClients").Row(new
|
||||||
|
{
|
||||||
|
Enable = 1,
|
||||||
|
Name = "Deluge",
|
||||||
|
Implementation = "Deluge",
|
||||||
|
Priority = 1,
|
||||||
|
Settings = new DelugeSettings85
|
||||||
|
{
|
||||||
|
Host = "127.0.0.1",
|
||||||
|
TvCategory = "abc",
|
||||||
|
UrlBase = "/my/"
|
||||||
|
}.ToJson(),
|
||||||
|
ConfigContract = "DelugeSettings"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients");
|
||||||
|
|
||||||
|
items.Should().HaveCount(1);
|
||||||
|
items.First().RemoveCompletedDownloads.Should().BeFalse();
|
||||||
|
items.First().RemoveFailedDownloads.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_disable_remove_for_existing_rtorrent()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("DownloadClients").Row(new
|
||||||
|
{
|
||||||
|
Enable = 1,
|
||||||
|
Name = "RTorrent",
|
||||||
|
Implementation = "RTorrent",
|
||||||
|
Priority = 1,
|
||||||
|
Settings = new RTorrentSettings
|
||||||
|
{
|
||||||
|
Host = "127.0.0.1",
|
||||||
|
TvCategory = "abc",
|
||||||
|
UrlBase = "/my/"
|
||||||
|
}.ToJson(),
|
||||||
|
ConfigContract = "RTorrentSettings"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = db.Query<DownloadClientDefinition158>("SELECT * FROM DownloadClients");
|
||||||
|
|
||||||
|
items.Should().HaveCount(1);
|
||||||
|
items.First().RemoveCompletedDownloads.Should().BeFalse();
|
||||||
|
items.First().RemoveFailedDownloads.Should().BeFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DownloadClientDefinition158
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public bool Enable { get; set; }
|
||||||
|
public int Priority { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Implementation { get; set; }
|
||||||
|
public JObject Settings { get; set; }
|
||||||
|
public string ConfigContract { get; set; }
|
||||||
|
public bool RemoveCompletedDownloads { get; set; }
|
||||||
|
public bool RemoveFailedDownloads { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -134,13 +134,6 @@ namespace NzbDrone.Core.Configuration
|
||||||
set { SetValue("EnableCompletedDownloadHandling", value); }
|
set { SetValue("EnableCompletedDownloadHandling", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveCompletedDownloads
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("RemoveCompletedDownloads", false); }
|
|
||||||
|
|
||||||
set { SetValue("RemoveCompletedDownloads", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AutoRedownloadFailed
|
public bool AutoRedownloadFailed
|
||||||
{
|
{
|
||||||
get { return GetValueBoolean("AutoRedownloadFailed", true); }
|
get { return GetValueBoolean("AutoRedownloadFailed", true); }
|
||||||
|
@ -148,13 +141,6 @@ namespace NzbDrone.Core.Configuration
|
||||||
set { SetValue("AutoRedownloadFailed", value); }
|
set { SetValue("AutoRedownloadFailed", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveFailedDownloads
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("RemoveFailedDownloads", true); }
|
|
||||||
|
|
||||||
set { SetValue("RemoveFailedDownloads", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateEmptySeriesFolders
|
public bool CreateEmptySeriesFolders
|
||||||
{
|
{
|
||||||
get { return GetValueBoolean("CreateEmptySeriesFolders", false); }
|
get { return GetValueBoolean("CreateEmptySeriesFolders", false); }
|
||||||
|
|
|
@ -19,10 +19,7 @@ namespace NzbDrone.Core.Configuration
|
||||||
|
|
||||||
//Completed/Failed Download Handling (Download client)
|
//Completed/Failed Download Handling (Download client)
|
||||||
bool EnableCompletedDownloadHandling { get; set; }
|
bool EnableCompletedDownloadHandling { get; set; }
|
||||||
bool RemoveCompletedDownloads { get; set; }
|
|
||||||
|
|
||||||
bool AutoRedownloadFailed { get; set; }
|
bool AutoRedownloadFailed { get; set; }
|
||||||
bool RemoveFailedDownloads { get; set; }
|
|
||||||
|
|
||||||
//Media Management
|
//Media Management
|
||||||
bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; }
|
bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; }
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentMigrator;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(158)]
|
||||||
|
public class cdh_per_downloadclient : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Alter.Table("DownloadClients")
|
||||||
|
.AddColumn("RemoveCompletedDownloads").AsBoolean().NotNullable().WithDefaultValue(true)
|
||||||
|
.AddColumn("RemoveFailedDownloads").AsBoolean().NotNullable().WithDefaultValue(true);
|
||||||
|
|
||||||
|
Execute.WithConnection(MoveRemoveSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveRemoveSettings(IDbConnection conn, IDbTransaction tran)
|
||||||
|
{
|
||||||
|
var removeCompletedDownloads = true;
|
||||||
|
var removeFailedDownloads = false;
|
||||||
|
|
||||||
|
using (var removeCompletedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removecompleteddownloads'"))
|
||||||
|
{
|
||||||
|
if ("False" == (removeCompletedDownloadsCmd.ExecuteScalar() as string))
|
||||||
|
removeCompletedDownloads = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var removeFailedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removefaileddownloads'"))
|
||||||
|
{
|
||||||
|
if ("True" == (removeFailedDownloadsCmd.ExecuteScalar() as string))
|
||||||
|
removeFailedDownloads = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation = \"RTorrent\" THEN 0 ELSE ? END), RemoveFailedDownloads = ?"))
|
||||||
|
{
|
||||||
|
updateClientCmd.AddParameter(removeCompletedDownloads ? 1 : 0);
|
||||||
|
updateClientCmd.AddParameter(removeFailedDownloads ? 1 : 0);
|
||||||
|
updateClientCmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
using (var removeConfigCmd = conn.CreateCommand(tran, $"DELETE FROM Config WHERE Key IN ('removecompleteddownloads', 'removefaileddownloads')"))
|
||||||
|
{
|
||||||
|
removeConfigCmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using FluentMigrator.Builders.Create;
|
using System.Data;
|
||||||
|
using FluentMigrator.Builders.Create;
|
||||||
using FluentMigrator.Builders.Create.Table;
|
using FluentMigrator.Builders.Create.Table;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
|
@ -10,7 +11,16 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
return expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity();
|
return expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddParameter(this System.Data.IDbCommand command, object value)
|
public static IDbCommand CreateCommand(this IDbConnection conn, IDbTransaction tran, string query)
|
||||||
|
{
|
||||||
|
var command = conn.CreateCommand();
|
||||||
|
command.Transaction = tran;
|
||||||
|
command.CommandText = query;
|
||||||
|
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddParameter(this IDbCommand command, object value)
|
||||||
{
|
{
|
||||||
var parameter = command.CreateParameter();
|
var parameter = command.CreateParameter();
|
||||||
parameter.Value = value;
|
parameter.Value = value;
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
|
|
||||||
// Check if torrent is finished and if it exceeds cached seedConfig
|
// Check if torrent is finished and if it exceeds cached seedConfig
|
||||||
item.CanMoveFiles = item.CanBeRemoved =
|
item.CanMoveFiles = item.CanBeRemoved =
|
||||||
torrent.IsFinished &&
|
torrent.IsFinished && seedConfig != null &&
|
||||||
(
|
(
|
||||||
(torrent.Ratio / 1000.0) >= seedConfig.Ratio ||
|
(torrent.Ratio / 1000.0) >= seedConfig.Ratio ||
|
||||||
(DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds(torrent.FinishedTime)) >= seedConfig.SeedTime
|
(DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds(torrent.FinishedTime)) >= seedConfig.SeedTime
|
||||||
|
|
|
@ -7,5 +7,8 @@ namespace NzbDrone.Core.Download
|
||||||
{
|
{
|
||||||
public DownloadProtocol Protocol { get; set; }
|
public DownloadProtocol Protocol { get; set; }
|
||||||
public int Priority { get; set; } = 1;
|
public int Priority { get; set; } = 1;
|
||||||
|
|
||||||
|
public bool RemoveCompletedDownloads { get; set; } = true;
|
||||||
|
public bool RemoveFailedDownloads { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,38 +27,65 @@ namespace NzbDrone.Core.Download
|
||||||
{
|
{
|
||||||
var trackedDownload = message.TrackedDownload;
|
var trackedDownload = message.TrackedDownload;
|
||||||
|
|
||||||
if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
|
if (trackedDownload == null ||
|
||||||
|
message.TrackedDownload.DownloadItem.Removed ||
|
||||||
|
!trackedDownload.DownloadItem.CanBeRemoved)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveFromDownloadClient(trackedDownload);
|
var downloadClient = _downloadClientProvider.Get(message.TrackedDownload.DownloadClient);
|
||||||
|
var definition = downloadClient.Definition as DownloadClientDefinition;
|
||||||
|
|
||||||
|
if (!definition.RemoveFailedDownloads)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveFromDownloadClient(trackedDownload, downloadClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(DownloadCompletedEvent message)
|
public void Handle(DownloadCompletedEvent message)
|
||||||
{
|
{
|
||||||
if (_configService.RemoveCompletedDownloads &&
|
var trackedDownload = message.TrackedDownload;
|
||||||
!message.TrackedDownload.DownloadItem.Removed &&
|
var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient);
|
||||||
message.TrackedDownload.DownloadItem.CanBeRemoved &&
|
var definition = downloadClient.Definition as DownloadClientDefinition;
|
||||||
message.TrackedDownload.DownloadItem.Status != DownloadItemStatus.Downloading)
|
|
||||||
|
MarkItemAsImported(trackedDownload, downloadClient);
|
||||||
|
|
||||||
|
if (trackedDownload.DownloadItem.Removed ||
|
||||||
|
!trackedDownload.DownloadItem.CanBeRemoved ||
|
||||||
|
trackedDownload.DownloadItem.Status == DownloadItemStatus.Downloading)
|
||||||
{
|
{
|
||||||
RemoveFromDownloadClient(message.TrackedDownload);
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!definition.RemoveCompletedDownloads)
|
||||||
{
|
{
|
||||||
MarkItemAsImported(message.TrackedDownload);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveFromDownloadClient(message.TrackedDownload, downloadClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(DownloadCanBeRemovedEvent message)
|
public void Handle(DownloadCanBeRemovedEvent message)
|
||||||
{
|
{
|
||||||
// Already verified that it can be removed, just needs to be removed
|
var trackedDownload = message.TrackedDownload;
|
||||||
RemoveFromDownloadClient(message.TrackedDownload);
|
var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient);
|
||||||
|
var definition = downloadClient.Definition as DownloadClientDefinition;
|
||||||
|
|
||||||
|
if (trackedDownload.DownloadItem.Removed ||
|
||||||
|
!trackedDownload.DownloadItem.CanBeRemoved ||
|
||||||
|
!definition.RemoveCompletedDownloads)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveFromDownloadClient(message.TrackedDownload, downloadClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveFromDownloadClient(TrackedDownload trackedDownload)
|
private void RemoveFromDownloadClient(TrackedDownload trackedDownload, IDownloadClient downloadClient)
|
||||||
{
|
{
|
||||||
var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.Debug("[{0}] Removing download from {1} history", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name);
|
_logger.Debug("[{0}] Removing download from {1} history", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name);
|
||||||
|
@ -75,9 +102,8 @@ namespace NzbDrone.Core.Download
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MarkItemAsImported(TrackedDownload trackedDownload)
|
private void MarkItemAsImported(TrackedDownload trackedDownload, IDownloadClient downloadClient)
|
||||||
{
|
{
|
||||||
var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.Debug("[{0}] Marking download as imported from {1}", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name);
|
_logger.Debug("[{0}] Marking download as imported from {1}", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name);
|
||||||
|
|
|
@ -48,7 +48,6 @@ namespace NzbDrone.Core.Download
|
||||||
public void Execute(ProcessMonitoredDownloadsCommand message)
|
public void Execute(ProcessMonitoredDownloadsCommand message)
|
||||||
{
|
{
|
||||||
var enableCompletedDownloadHandling = _configService.EnableCompletedDownloadHandling;
|
var enableCompletedDownloadHandling = _configService.EnableCompletedDownloadHandling;
|
||||||
var removeCompletedDownloads = _configService.RemoveCompletedDownloads;
|
|
||||||
var trackedDownloads = _trackedDownloadService.GetTrackedDownloads()
|
var trackedDownloads = _trackedDownloadService.GetTrackedDownloads()
|
||||||
.Where(t => t.IsTrackable)
|
.Where(t => t.IsTrackable)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -73,10 +72,7 @@ namespace NzbDrone.Core.Download
|
||||||
}
|
}
|
||||||
|
|
||||||
// Imported downloads are no longer trackable so process them after processing trackable downloads
|
// Imported downloads are no longer trackable so process them after processing trackable downloads
|
||||||
if (removeCompletedDownloads)
|
RemoveCompletedDownloads();
|
||||||
{
|
|
||||||
RemoveCompletedDownloads();
|
|
||||||
}
|
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,7 @@ namespace Sonarr.Api.V3.Config
|
||||||
public string DownloadClientWorkingFolders { get; set; }
|
public string DownloadClientWorkingFolders { get; set; }
|
||||||
|
|
||||||
public bool EnableCompletedDownloadHandling { get; set; }
|
public bool EnableCompletedDownloadHandling { get; set; }
|
||||||
public bool RemoveCompletedDownloads { get; set; }
|
|
||||||
|
|
||||||
public bool AutoRedownloadFailed { get; set; }
|
public bool AutoRedownloadFailed { get; set; }
|
||||||
public bool RemoveFailedDownloads { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DownloadClientConfigResourceMapper
|
public static class DownloadClientConfigResourceMapper
|
||||||
|
@ -23,10 +20,7 @@ namespace Sonarr.Api.V3.Config
|
||||||
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
|
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
|
||||||
|
|
||||||
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
|
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
|
||||||
RemoveCompletedDownloads = model.RemoveCompletedDownloads,
|
AutoRedownloadFailed = model.AutoRedownloadFailed
|
||||||
|
|
||||||
AutoRedownloadFailed = model.AutoRedownloadFailed,
|
|
||||||
RemoveFailedDownloads = model.RemoveFailedDownloads
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace Sonarr.Api.V3.DownloadClient
|
||||||
public bool Enable { get; set; }
|
public bool Enable { get; set; }
|
||||||
public DownloadProtocol Protocol { get; set; }
|
public DownloadProtocol Protocol { get; set; }
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
public bool RemoveCompletedDownloads { get; set; }
|
||||||
|
public bool RemoveFailedDownloads { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DownloadClientResourceMapper : ProviderResourceMapper<DownloadClientResource, DownloadClientDefinition>
|
public class DownloadClientResourceMapper : ProviderResourceMapper<DownloadClientResource, DownloadClientDefinition>
|
||||||
|
@ -21,6 +23,8 @@ namespace Sonarr.Api.V3.DownloadClient
|
||||||
resource.Enable = definition.Enable;
|
resource.Enable = definition.Enable;
|
||||||
resource.Protocol = definition.Protocol;
|
resource.Protocol = definition.Protocol;
|
||||||
resource.Priority = definition.Priority;
|
resource.Priority = definition.Priority;
|
||||||
|
resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads;
|
||||||
|
resource.RemoveFailedDownloads = definition.RemoveFailedDownloads;
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +38,8 @@ namespace Sonarr.Api.V3.DownloadClient
|
||||||
definition.Enable = resource.Enable;
|
definition.Enable = resource.Enable;
|
||||||
definition.Protocol = resource.Protocol;
|
definition.Protocol = resource.Protocol;
|
||||||
definition.Priority = resource.Priority;
|
definition.Priority = resource.Priority;
|
||||||
|
definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads;
|
||||||
|
definition.RemoveFailedDownloads = resource.RemoveFailedDownloads;
|
||||||
|
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue