mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
fix: check if the file still exists in the service before deleting (#1476)
This PR add a check to verify if the item to be deleted inside the *arr service still exists before actually sending the delete request.
This commit is contained in:
@@ -237,6 +237,19 @@ mediaRoutes.delete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMovie) {
|
if (isMovie) {
|
||||||
|
// check if the movie exists
|
||||||
|
try {
|
||||||
|
await (service as RadarrAPI).getMovie({
|
||||||
|
id: parseInt(
|
||||||
|
is4k
|
||||||
|
? (media.externalServiceSlug4k as string)
|
||||||
|
: (media.externalServiceSlug as string)
|
||||||
|
),
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return res.status(204).send();
|
||||||
|
}
|
||||||
|
// remove the movie
|
||||||
await (service as RadarrAPI).removeMovie(
|
await (service as RadarrAPI).removeMovie(
|
||||||
parseInt(
|
parseInt(
|
||||||
is4k
|
is4k
|
||||||
@@ -251,6 +264,13 @@ mediaRoutes.delete(
|
|||||||
if (!tvdbId) {
|
if (!tvdbId) {
|
||||||
throw new Error('TVDB ID not found');
|
throw new Error('TVDB ID not found');
|
||||||
}
|
}
|
||||||
|
// check if the series exists
|
||||||
|
try {
|
||||||
|
await (service as SonarrAPI).getSeriesByTvdbId(tvdbId);
|
||||||
|
} catch {
|
||||||
|
return res.status(204).send();
|
||||||
|
}
|
||||||
|
// remove the series
|
||||||
await (service as SonarrAPI).removeSerie(tvdbId);
|
await (service as SonarrAPI).removeSerie(tvdbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user