fix(servarr): handle servaarr server being unavailable when scanning downloads (#2358)

This commit is contained in:
Danshil Kokil Mungur
2021-12-25 05:02:03 +04:00
committed by GitHub
parent 2ded8f5484
commit 488874fc17

View File

@@ -76,6 +76,7 @@ class DownloadTracker {
url: RadarrAPI.buildUrl(server, '/api/v3'), url: RadarrAPI.buildUrl(server, '/api/v3'),
}); });
try {
const queueItems = await radarr.getQueue(); const queueItems = await radarr.getQueue();
this.radarrServers[server.id] = queueItems.map((item) => ({ this.radarrServers[server.id] = queueItems.map((item) => ({
@@ -95,6 +96,14 @@ class DownloadTracker {
{ label: 'Download Tracker' } { label: 'Download Tracker' }
); );
} }
} catch {
logger.error(
`Unable to get queue from Radarr server: ${server.name}`,
{
label: 'Download Tracker',
}
);
}
// Duplicate this data to matching servers // Duplicate this data to matching servers
const matchingServers = settings.radarr.filter( const matchingServers = settings.radarr.filter(
@@ -134,16 +143,17 @@ class DownloadTracker {
); );
}); });
// Load downloads from Radarr servers // Load downloads from Sonarr servers
Promise.all( Promise.all(
filteredServers.map(async (server) => { filteredServers.map(async (server) => {
if (server.syncEnabled) { if (server.syncEnabled) {
const radarr = new SonarrAPI({ const sonarr = new SonarrAPI({
apiKey: server.apiKey, apiKey: server.apiKey,
url: SonarrAPI.buildUrl(server, '/api/v3'), url: SonarrAPI.buildUrl(server, '/api/v3'),
}); });
const queueItems = await radarr.getQueue(); try {
const queueItems = await sonarr.getQueue();
this.sonarrServers[server.id] = queueItems.map((item) => ({ this.sonarrServers[server.id] = queueItems.map((item) => ({
externalId: item.seriesId, externalId: item.seriesId,
@@ -162,14 +172,22 @@ class DownloadTracker {
{ label: 'Download Tracker' } { label: 'Download Tracker' }
); );
} }
} catch {
logger.error(
`Unable to get queue from Sonarr server: ${server.name}`,
{
label: 'Download Tracker',
}
);
}
// Duplicate this data to matching servers // Duplicate this data to matching servers
const matchingServers = settings.sonarr.filter( const matchingServers = settings.sonarr.filter(
(rs) => (ss) =>
rs.hostname === server.hostname && ss.hostname === server.hostname &&
rs.port === server.port && ss.port === server.port &&
rs.baseUrl === server.baseUrl && ss.baseUrl === server.baseUrl &&
rs.id !== server.id ss.id !== server.id
); );
if (matchingServers.length > 0) { if (matchingServers.length > 0) {