From 861dddfbbe47d4ec4bffe7a64abb98c8d92aff94 Mon Sep 17 00:00:00 2001 From: Salvoxia Date: Sun, 18 Aug 2024 12:07:43 +0200 Subject: [PATCH] Sync Mode Explicitly check for 403 status codes when fetching libraries or triggering offline asset removal to throw the appropriate error --- immich_auto_album.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/immich_auto_album.py b/immich_auto_album.py index 56a7c99..ef924c6 100644 --- a/immich_auto_album.py +++ b/immich_auto_album.py @@ -478,7 +478,10 @@ def fetchLibraries(): apiEndpoint = 'libraries' r = requests.get(root_url+apiEndpoint, **requests_kwargs) - assert r.status_code in [200, 201] + if r.status_code == 403: + logging.fatal("--sync-mode 2 requires an Admin User API key!") + else: + assert r.status_code in [200, 201] return r.json() def triggerOfflineAssetRemoval(libraryId: str): @@ -497,7 +500,10 @@ def triggerOfflineAssetRemoval(libraryId: str): apiEndpoint = 'libraries/'+libraryId+'/removeOffline' r = requests.post(root_url+apiEndpoint, **requests_kwargs) - assert r.status_code == 204 + if r.status_code == 403: + logging.fatal("--sync-mode 2 requires an Admin User API key!") + else: + assert r.status_code == 204 # append trailing slash to all root paths