diff options
author | Andrew Godwin | 2022-12-17 15:00:50 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-17 15:00:50 -0700 |
commit | d08324e1590df4a7da19b70430e4abe364850d9b (patch) | |
tree | fd29564d771dd86f55bf5e944e8b3997a78f7ff8 /users/models | |
parent | 64f113dd8d102282da8f013ab2acf6e1c24a5934 (diff) | |
download | takahe-d08324e1590df4a7da19b70430e4abe364850d9b.tar.gz takahe-d08324e1590df4a7da19b70430e4abe364850d9b.tar.bz2 takahe-d08324e1590df4a7da19b70430e4abe364850d9b.zip |
Handle timeouts on image fetch
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/identity.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/users/models/identity.py b/users/models/identity.py index c8a154c..afec0e7 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -46,11 +46,15 @@ class IdentityStates(StateGraph): if await identity.fetch_actor(): # Also stash their icon if we can if identity.icon_uri: - file, mimetype = await get_remote_file( - identity.icon_uri, - timeout=settings.SETUP.REMOTE_TIMEOUT, - max_size=settings.SETUP.AVATAR_MAX_IMAGE_FILESIZE_KB * 1024, - ) + try: + file, mimetype = await get_remote_file( + identity.icon_uri, + timeout=settings.SETUP.REMOTE_TIMEOUT, + max_size=settings.SETUP.AVATAR_MAX_IMAGE_FILESIZE_KB * 1024, + ) + except httpx.RequestError: + # We've still got enough info to consider ourselves updated + return cls.updated if file: identity.icon = file await sync_to_async(identity.save)() |