Added the ability to skip redownload when marking an item as failed in the activity queue

This commit is contained in:
PearsonFlyer 2023-07-13 14:57:57 -04:00
parent 3aa3ac90ed
commit bdbfa8313c
12 changed files with 14035 additions and 1680 deletions

View File

@ -44,7 +44,7 @@ class QueueRow extends Component {
this.setState({ isRemoveQueueItemModalOpen: true });
};
onRemoveQueueItemModalConfirmed = (blocklist) => {
onRemoveQueueItemModalConfirmed = (blocklist, skipredownload) => {
const {
onRemoveQueueItemPress,
onQueueRowModalOpenOrClose
@ -52,6 +52,7 @@ class QueueRow extends Component {
onQueueRowModalOpenOrClose(false);
onRemoveQueueItemPress(blocklist);
onRemoveQueueItemPress(skipredownload);
this.setState({ isRemoveQueueItemModalOpen: false });
};

View File

@ -10,6 +10,7 @@ import ModalContent from 'Components/Modal/ModalContent';
import ModalFooter from 'Components/Modal/ModalFooter';
import ModalHeader from 'Components/Modal/ModalHeader';
import { inputTypes, kinds, sizes } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
class RemoveQueueItemModal extends Component {
@ -21,7 +22,8 @@ class RemoveQueueItemModal extends Component {
this.state = {
remove: true,
blocklist: false
blocklist: false,
skipredownload: false
};
}
@ -31,7 +33,8 @@ class RemoveQueueItemModal extends Component {
resetState = function() {
this.setState({
remove: true,
blocklist: false
blocklist: false,
skipredownload: false
});
};
@ -46,6 +49,10 @@ class RemoveQueueItemModal extends Component {
this.setState({ blocklist: value });
};
onSkipReDownloadChange = ({ value }) => {
this.setState({ skipredownload: value });
};
onRemoveConfirmed = () => {
const state = this.state;
@ -69,7 +76,7 @@ class RemoveQueueItemModal extends Component {
isPending
} = this.props;
const { remove, blocklist } = this.state;
const { remove, blocklist, skipredownload } = this.state;
return (
<Modal
@ -118,6 +125,19 @@ class RemoveQueueItemModal extends Component {
/>
</FormGroup>
{
blocklist &&
<FormGroup>
<FormLabel>{translate('SkipRedownload')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="skipredownload"
value={skipredownload}
helpText={translate('SkipRedownloadHelpText')}
onChange={this.onSkipReDownloadChange}
/>
</FormGroup>
}
</ModalBody>
<ModalFooter>

View File

@ -23,7 +23,8 @@ class RemoveQueueItemsModal extends Component {
this.state = {
remove: true,
blocklist: false
blocklist: false,
skipredownload: false
};
}
@ -33,7 +34,8 @@ class RemoveQueueItemsModal extends Component {
resetState = function() {
this.setState({
remove: true,
blocklist: false
blocklist: false,
skipredownload: false
});
};
@ -48,6 +50,10 @@ class RemoveQueueItemsModal extends Component {
this.setState({ blocklist: value });
};
onSkipReDownloadChange = ({ value }) => {
this.setState({ skipredownload: value });
};
onRemoveConfirmed = () => {
const state = this.state;
@ -71,7 +77,7 @@ class RemoveQueueItemsModal extends Component {
allPending
} = this.props;
const { remove, blocklist } = this.state;
const { remove, blocklist, skipredownload } = this.state;
return (
<Modal
@ -122,6 +128,19 @@ class RemoveQueueItemsModal extends Component {
/>
</FormGroup>
{
blocklist &&
<FormGroup>
<FormLabel>{translate('SkipRedownload')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="skipredownload"
value={skipredownload}
helpText={translate('SkipRedownloadHelpText')}
onChange={this.onSkipReDownloadChange}
/>
</FormGroup>
}
</ModalBody>
<ModalFooter>

View File

@ -381,13 +381,14 @@ export const actionHandlers = handleThunks({
const {
id,
remove,
blocklist
blocklist,
skipredownload
} = payload;
dispatch(updateItem({ section: paged, id, isRemoving: true }));
const promise = createAjaxRequest({
url: `/queue/${id}?removeFromClient=${remove}&blocklist=${blocklist}`,
url: `/queue/${id}?removeFromClient=${remove}&blocklist=${blocklist}&skipredownload=${skipredownload}`,
method: 'DELETE'
}).request;
@ -404,7 +405,8 @@ export const actionHandlers = handleThunks({
const {
ids,
remove,
blocklist
blocklist,
skipredownload
} = payload;
dispatch(batchActions([
@ -420,7 +422,7 @@ export const actionHandlers = handleThunks({
]));
const promise = createAjaxRequest({
url: `/queue/bulk?removeFromClient=${remove}&blocklist=${blocklist}`,
url: `/queue/bulk?removeFromClient=${remove}&blocklist=${blocklist}&skipredownload=${skipredownload}`,
method: 'DELETE',
dataType: 'json',
contentType: 'application/json',

12428
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@
"@types/react-router-dom": "5.3.3",
"@types/react-text-truncate": "0.14.1",
"@types/react-window": "1.8.5",
"@types/redux-actions": "2.6.2",
"@types/redux-actions": "^2.6.2",
"@types/webpack-livereload-plugin": "^2.3.3",
"@typescript-eslint/eslint-plugin": "5.59.5",
"@typescript-eslint/parser": "5.59.5",

View File

@ -23,5 +23,6 @@ namespace NzbDrone.Core.Download
public Dictionary<string, string> Data { get; set; }
public TrackedDownload TrackedDownload { get; set; }
public List<Language> Languages { get; set; }
public bool SkipReDownload { get; set; }
}
}

View File

@ -9,8 +9,8 @@ namespace NzbDrone.Core.Download
{
public interface IFailedDownloadService
{
void MarkAsFailed(int historyId);
void MarkAsFailed(string downloadId);
void MarkAsFailed(int historyId, bool skipReDownload = false);
void MarkAsFailed(string downloadId, bool skipReDownload = false);
void Check(TrackedDownload trackedDownload);
void ProcessFailed(TrackedDownload trackedDownload);
}
@ -30,14 +30,14 @@ namespace NzbDrone.Core.Download
_eventAggregator = eventAggregator;
}
public void MarkAsFailed(int historyId)
public void MarkAsFailed(int historyId, bool skipReDownload = false)
{
var history = _historyService.Get(historyId);
var downloadId = history.DownloadId;
if (downloadId.IsNullOrWhiteSpace())
{
PublishDownloadFailedEvent(new List<EpisodeHistory> { history }, "Manually marked as failed");
PublishDownloadFailedEvent(new List<EpisodeHistory> { history }, "Manually marked as failed", skipReDownload: skipReDownload);
return;
}
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download
PublishDownloadFailedEvent(grabbedHistory, "Manually marked as failed");
}
public void MarkAsFailed(string downloadId)
public void MarkAsFailed(string downloadId, bool skipReDownload = false)
{
var history = _historyService.Find(downloadId, EpisodeHistoryEventType.Grabbed);
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Download
{
var trackedDownload = _trackedDownloadService.Find(downloadId);
PublishDownloadFailedEvent(history, "Manually marked as failed", trackedDownload);
PublishDownloadFailedEvent(history, "Manually marked as failed", trackedDownload, skipReDownload: skipReDownload);
}
}
@ -125,7 +125,7 @@ namespace NzbDrone.Core.Download
PublishDownloadFailedEvent(grabbedItems, failure, trackedDownload);
}
private void PublishDownloadFailedEvent(List<EpisodeHistory> historyItems, string message, TrackedDownload trackedDownload = null)
private void PublishDownloadFailedEvent(List<EpisodeHistory> historyItems, string message, TrackedDownload trackedDownload = null, bool skipReDownload = false)
{
var historyItem = historyItems.First();
@ -140,7 +140,8 @@ namespace NzbDrone.Core.Download
Message = message,
Data = historyItem.Data,
TrackedDownload = trackedDownload,
Languages = historyItem.Languages
Languages = historyItem.Languages,
SkipReDownload = skipReDownload
};
_eventAggregator.PublishEvent(downloadFailedEvent);

View File

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.IndexerSearch;
@ -30,6 +30,12 @@ namespace NzbDrone.Core.Download
[EventHandleOrder(EventHandleOrder.Last)]
public void Handle(DownloadFailedEvent message)
{
if (message.SkipReDownload)
{
_logger.Debug("Skip redownloading requested by user");
return;
}
if (!_configService.AutoRedownloadFailed)
{
_logger.Debug("Auto redownloading failed episodes is disabled");

View File

@ -145,6 +145,8 @@
"ShowAdvanced": "Show Advanced",
"ShownClickToHide": "Shown, click to hide",
"SizeOnDisk": "Size on disk",
"SkipRedownloadHelpText": "Prevents Sonarr from trying to download an alternative release for this item",
"SkipRedownload": "Skip Redownload",
"SystemTimeHealthCheckMessage": "System time is off by more than 1 day. Scheduled tasks may not run correctly until the time is corrected",
"Tags": "Tags",
"UI Language": "UI Language",

View File

@ -70,7 +70,7 @@ namespace Sonarr.Api.V3.Queue
}
[RestDeleteById]
public void RemoveAction(int id, bool removeFromClient = true, bool blocklist = false)
public void RemoveAction(int id, bool removeFromClient = true, bool blocklist = false, bool skipReDownload = false)
{
var pendingRelease = _pendingReleaseService.FindPendingQueueItem(id);
@ -88,12 +88,12 @@ namespace Sonarr.Api.V3.Queue
throw new NotFoundException();
}
Remove(trackedDownload, removeFromClient, blocklist);
Remove(trackedDownload, removeFromClient, blocklist, skipReDownload);
_trackedDownloadService.StopTracking(trackedDownload.DownloadItem.DownloadId);
}
[HttpDelete("bulk")]
public object RemoveMany([FromBody] QueueBulkResource resource, [FromQuery] bool removeFromClient = true, [FromQuery] bool blocklist = false)
public object RemoveMany([FromBody] QueueBulkResource resource, [FromQuery] bool removeFromClient = true, [FromQuery] bool blocklist = false, [FromQuery] bool skipReDownload = false)
{
var trackedDownloadIds = new List<string>();
var pendingToRemove = new List<NzbDrone.Core.Queue.Queue>();
@ -124,7 +124,7 @@ namespace Sonarr.Api.V3.Queue
foreach (var trackedDownload in trackedToRemove.DistinctBy(t => t.DownloadItem.DownloadId))
{
Remove(trackedDownload, removeFromClient, blocklist);
Remove(trackedDownload, removeFromClient, blocklist, skipReDownload);
trackedDownloadIds.Add(trackedDownload.DownloadItem.DownloadId);
}
@ -255,7 +255,7 @@ namespace Sonarr.Api.V3.Queue
_pendingReleaseService.RemovePendingQueueItems(pendingRelease.Id);
}
private TrackedDownload Remove(TrackedDownload trackedDownload, bool removeFromClient, bool blocklist)
private TrackedDownload Remove(TrackedDownload trackedDownload, bool removeFromClient, bool blocklist, bool skipReDownload)
{
if (removeFromClient)
{
@ -271,7 +271,7 @@ namespace Sonarr.Api.V3.Queue
if (blocklist)
{
_failedDownloadService.MarkAsFailed(trackedDownload.DownloadItem.DownloadId);
_failedDownloadService.MarkAsFailed(trackedDownload.DownloadItem.DownloadId, skipReDownload);
}
if (!removeFromClient && !blocklist)

3181
yarn.lock

File diff suppressed because it is too large Load Diff