From df513d5eef7a43d65d0d62291e94abc02b11b53f Mon Sep 17 00:00:00 2001 From: Ben Scobie Date: Wed, 20 Nov 2024 09:22:19 +0000 Subject: [PATCH 1/3] chore: Ensure .sh files always have LF line endings --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..526c8a38 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf \ No newline at end of file From e299c1508ecf0718f8acf6f4cfdbbc24777fe3be Mon Sep 17 00:00:00 2001 From: Ben Scobie Date: Wed, 20 Nov 2024 09:38:57 +0000 Subject: [PATCH 2/3] fix: Handling collections failure after multi arr --- .../modules/api/servarr-api/helpers/sonarr.helper.ts | 12 +++++++----- .../src/modules/api/servarr-api/servarr.service.ts | 8 ++++---- .../modules/collections/collection-worker.service.ts | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/src/modules/api/servarr-api/helpers/sonarr.helper.ts b/server/src/modules/api/servarr-api/helpers/sonarr.helper.ts index 60218d55..8e4d1983 100644 --- a/server/src/modules/api/servarr-api/helpers/sonarr.helper.ts +++ b/server/src/modules/api/servarr-api/helpers/sonarr.helper.ts @@ -370,6 +370,13 @@ export class SonarrApi extends ServarrApi<{ } } } + + this.logger.log( + `Unmonitored ${ + typeof type === 'number' ? `season ${type}` : 'seasons' + } from Sonarr show with ID ${seriesId}`, + ); + return data; } catch (e) { this.logger.log("Couldn't unmonitor/delete. Does it exist in sonarr?", { @@ -379,11 +386,6 @@ export class SonarrApi extends ServarrApi<{ }); this.logger.debug(e); } - this.logger.log( - `Unmonitored ${ - typeof type === 'number' ? `season ${type}` : 'seasons' - } from Sonarr show with ID ${seriesId}`, - ); } private buildSeasonList( diff --git a/server/src/modules/api/servarr-api/servarr.service.ts b/server/src/modules/api/servarr-api/servarr.service.ts index 5c908a96..02ba2a3c 100644 --- a/server/src/modules/api/servarr-api/servarr.service.ts +++ b/server/src/modules/api/servarr-api/servarr.service.ts @@ -9,8 +9,8 @@ import { SonarrSettingRawDto } from "../../settings/dto's/sonarr-setting.dto"; @Injectable() export class ServarrService { SonarrApi: SonarrApi; - private radarrApiCache?: Record = {}; - private sonarrApiCache?: Record = {}; + private radarrApiCache: Record = {}; + private sonarrApiCache: Record = {}; constructor( @Inject(forwardRef(() => SettingsService)) @@ -27,7 +27,7 @@ export class ServarrService { if (!this.sonarrApiCache[id]) { const setting = await this.settings.getSonarrSetting(id); - if (!('id' in setting)) { + if (setting == null || !('id' in setting)) { throw new Error('Sonarr setting not found'); } @@ -57,7 +57,7 @@ export class ServarrService { if (!this.radarrApiCache[id]) { const setting = await this.settings.getRadarrSetting(id); - if (!('id' in setting)) { + if (setting == null || !('id' in setting)) { throw new Error('Radarr setting not found'); } diff --git a/server/src/modules/collections/collection-worker.service.ts b/server/src/modules/collections/collection-worker.service.ts index 8ec02883..f533a47f 100644 --- a/server/src/modules/collections/collection-worker.service.ts +++ b/server/src/modules/collections/collection-worker.service.ts @@ -143,12 +143,12 @@ export class CollectionWorkerService extends TaskBase { this.collectionService.saveCollection(collection); - const radarrApiClient = collection.radarrSettings.id - ? await this.servarrApi.getRadarrApiClient(collection.radarrSettings.id) + const radarrApiClient = collection.radarrSettingsId + ? await this.servarrApi.getRadarrApiClient(collection.radarrSettingsId) : undefined; - const sonarrApiClient = collection.sonarrSettings.id - ? await this.servarrApi.getSonarrApiClient(collection.sonarrSettings.id) + const sonarrApiClient = collection.sonarrSettingsId + ? await this.servarrApi.getSonarrApiClient(collection.sonarrSettingsId) : undefined; if (plexLibrary.type === 'movie') { From 8cd00301410c7eef1c2ac973834bafd6416e73d0 Mon Sep 17 00:00:00 2001 From: Ben Scobie Date: Wed, 20 Nov 2024 10:38:01 +0000 Subject: [PATCH 3/3] fix: Sonarr media existence check in collection handling --- .../collections/collection-worker.service.ts | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/server/src/modules/collections/collection-worker.service.ts b/server/src/modules/collections/collection-worker.service.ts index f533a47f..d571def2 100644 --- a/server/src/modules/collections/collection-worker.service.ts +++ b/server/src/modules/collections/collection-worker.service.ts @@ -256,7 +256,7 @@ export class CollectionWorkerService extends TaskBase { if (tvdbId) { let sonarrMedia = await sonarrApiClient.getSeriesByTvdbId(tvdbId); - if (sonarrMedia) { + if (sonarrMedia?.id) { switch (collection.arrAction) { case ServarrAction.DELETE: switch (collection.type) { @@ -322,12 +322,16 @@ export class CollectionWorkerService extends TaskBase { 'all', false, ); - // unmonitor show - sonarrMedia.monitored = false; - sonarrApiClient.updateSeries(sonarrMedia); - this.infoLogger( - `[Sonarr] Unmonitored show '${sonarrMedia.title}'`, - ); + + if (sonarrMedia) { + // unmonitor show + sonarrMedia.monitored = false; + sonarrApiClient.updateSeries(sonarrMedia); + this.infoLogger( + `[Sonarr] Unmonitored show '${sonarrMedia.title}'`, + ); + } + break; } break; @@ -360,12 +364,16 @@ export class CollectionWorkerService extends TaskBase { 'all', true, ); - // unmonitor show - sonarrMedia.monitored = false; - sonarrApiClient.updateSeries(sonarrMedia); - this.infoLogger( - `[Sonarr] Unmonitored show '${sonarrMedia.title}' and removed all episodes`, - ); + + if (sonarrMedia) { + // unmonitor show + sonarrMedia.monitored = false; + sonarrApiClient.updateSeries(sonarrMedia); + this.infoLogger( + `[Sonarr] Unmonitored show '${sonarrMedia.title}' and removed all episodes`, + ); + } + break; } break; @@ -399,12 +407,16 @@ export class CollectionWorkerService extends TaskBase { 'existing', true, ); - // unmonitor show - sonarrMedia.monitored = false; - sonarrApiClient.updateSeries(sonarrMedia); - this.infoLogger( - `[Sonarr] Unmonitored show '${sonarrMedia.title}' and Removed exisiting episodes`, - ); + + if (sonarrMedia) { + // unmonitor show + sonarrMedia.monitored = false; + sonarrApiClient.updateSeries(sonarrMedia); + this.infoLogger( + `[Sonarr] Unmonitored show '${sonarrMedia.title}' and Removed exisiting episodes`, + ); + } + break; } break;