Skip to content

Commit

Permalink
Merge pull request #50 from Salvoxia/enhancement/serverVersionCheck
Browse files Browse the repository at this point in the history
Enhancement: Server Version Check
  • Loading branch information
Salvoxia authored Sep 15, 2024
2 parents eb0ba51 + bd72108 commit e767ee0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions immich_auto_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def fetchServerVersion() -> dict:
"""
Fetches the API version from the immich server.
If the API endpoint does not yet exist, returns the latest version
before that API endpoint was introduced: 1.105.1
If the API endpoint for getting the server version cannot be reached,
raises HTTPError
Returns
-------
Expand All @@ -304,17 +304,13 @@ def fetchServerVersion() -> dict:
# This API call was only introduced with version 1.106.1, so it will fail
# for older versions.
# Initialize the version with the latest version without this API call
version = {'major': 1, 'minor': 105, "patch": 1}
r = requests.get(root_url+'server-info/version', **requests_kwargs)
assert r.status_code == 200 or r.status_code == 404
if r.status_code == 200:
version = r.json()
logging.info("Detected Immich server version %s.%s.%s", version['major'], version['minor'], version['patch'])
# Since the API call did not exist prior to 1.106.1, we assume that 404 means we found an old version.
elif r.status_code == 404:
logging.info("Detected Immich server version %s.%s.%s or older", version['major'], version['minor'], version['patch'])
# Any other errors mean communication error with API
else:
logging.error("Communication with Immich API failed! Make sure the passed API URL is correct!")
r.raise_for_status()
return version

Expand Down

0 comments on commit e767ee0

Please sign in to comment.