Skip to content

Commit 2557939

Browse files
committed
Avoid caching when API call fails
Check the return code of the bash function call and only store the result in the cache if the call was successful. This avoids caching empty values.
1 parent d70505a commit 2557939

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/info.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function bashio::info() {
3131
info=$(bashio::cache.get 'info')
3232
else
3333
info=$(bashio::api.supervisor GET /info false)
34+
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
35+
bashio::log.error "Failed to get info from Supervisor API"
36+
return "${__BASHIO_EXIT_NOK}"
37+
fi
3438
bashio::cache.set 'info' "${info}"
3539
fi
3640

0 commit comments

Comments
 (0)