Skip to content

Commit f773e0f

Browse files
authoredMar 15, 2025··
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.
1 parent 767a241 commit f773e0f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎server/routes/media.ts

+20
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,19 @@ mediaRoutes.delete(
237237
}
238238

239239
if (isMovie) {
240+
// check if the movie exists
241+
try {
242+
await (service as RadarrAPI).getMovie({
243+
id: parseInt(
244+
is4k
245+
? (media.externalServiceSlug4k as string)
246+
: (media.externalServiceSlug as string)
247+
),
248+
});
249+
} catch {
250+
return res.status(204).send();
251+
}
252+
// remove the movie
240253
await (service as RadarrAPI).removeMovie(
241254
parseInt(
242255
is4k
@@ -251,6 +264,13 @@ mediaRoutes.delete(
251264
if (!tvdbId) {
252265
throw new Error('TVDB ID not found');
253266
}
267+
// check if the series exists
268+
try {
269+
await (service as SonarrAPI).getSeriesByTvdbId(tvdbId);
270+
} catch {
271+
return res.status(204).send();
272+
}
273+
// remove the series
254274
await (service as SonarrAPI).removeSerie(tvdbId);
255275
}
256276

0 commit comments

Comments
 (0)
Please sign in to comment.