Skip to content

Commit

Permalink
Improve handling of empty library and caching for async_browse
Browse files Browse the repository at this point in the history
  • Loading branch information
rajlaud committed Oct 16, 2020
1 parent f602b85 commit e9f4238
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pysqueezebox/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ async def async_get_category(self, category, limit=None, search=None):
return await self.async_query_category(category, limit, search)

status = await self.async_status()
if "lastscan" in status and self.__dict__[category]:
if "lastscan" in status and self.__dict__[category] is not None:
if status["lastscan"] <= self.__dict__[category][0]:
_LOGGER.debug("Using cached category %s", category)
return self.__dict__[category][1]
Expand All @@ -306,8 +306,8 @@ async def async_get_category(self, category, limit=None, search=None):
_LOGGER.debug("Category %s not set", category)
result = await self.async_query_category(category)
status = await self.async_status()
self.__dict__[category] = (status.get("lastscan"), result)
if limit:
self.__dict__[category] = (status.get("lastscan", 0), result)
if limit and self.__dict__[category][1] is not None:
return self.__dict__[category][1][:limit]
return self.__dict__[category][1]

Expand Down

0 comments on commit e9f4238

Please sign in to comment.