Fixed: Mark as Failed errors (#5939)

Originally by Markus McDowall (cherry picked from commit 12fafb24578d39df2eabd2331558b2da961fe8b6)

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>

Fixes: #5907
Fixes: #5938
This commit is contained in:
nitsua 2021-02-14 10:28:30 -05:00 committed by GitHub
parent 90289de22c
commit a9792973ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -232,11 +232,9 @@ export const actionHandlers = handleThunks({
})); }));
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/history/failed', url: `/history/failed/${id}`,
method: 'POST', method: 'POST',
data: { dataType: 'json'
id
}
}).request; }).request;
promise.done(() => { promise.done(() => {

View File

@ -77,11 +77,8 @@ export const actionHandlers = handleThunks({
} = payload; } = payload;
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/history/failed', url: `/history/failed/${historyId}`,
method: 'POST', method: 'POST'
data: {
id: historyId
}
}).request; }).request;
promise.done(() => { promise.done(() => {

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Nancy;
using NzbDrone.Core.CustomFormats; using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications;
@ -39,6 +38,7 @@ namespace Radarr.Api.V3.History
Get("/since", x => GetHistorySince()); Get("/since", x => GetHistorySince());
Get("/movie", x => GetMovieHistory()); Get("/movie", x => GetMovieHistory());
Post("/failed", x => MarkAsFailed()); Post("/failed", x => MarkAsFailed());
Post(@"/failed/(?<id>[\d]{1,10})", x => MarkAsFailed((int)x.Id));
} }
protected HistoryResource MapToResource(MovieHistory model, bool includeMovie) protected HistoryResource MapToResource(MovieHistory model, bool includeMovie)
@ -130,10 +130,18 @@ namespace Radarr.Api.V3.History
return _historyService.GetByMovieId(movieId, eventType).Select(h => MapToResource(h, includeMovie)).ToList(); return _historyService.GetByMovieId(movieId, eventType).Select(h => MapToResource(h, includeMovie)).ToList();
} }
// v4 TODO: Getting the ID from the form is atypical, consider removing.
private object MarkAsFailed() private object MarkAsFailed()
{ {
var id = (int)Request.Form.Id; var id = (int)Request.Form.Id;
return MarkAsFailed(id);
}
private object MarkAsFailed(int id)
{
_failedDownloadService.MarkAsFailed(id); _failedDownloadService.MarkAsFailed(id);
return new object(); return new object();
} }
} }