mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +00:00
Fix list handling
This commit is contained in:
parent
9e1d6c9d2b
commit
422dd78489
@ -71,9 +71,8 @@ class AddonManager(AddonsData):
|
||||
"""Remove a custom repository."""
|
||||
for repo in self.repositories:
|
||||
if repo.url == url:
|
||||
repo = self.repositories.pop(repo, repo)
|
||||
self.repositories.pop(repo).remove()
|
||||
self.config.drop_addon_repository(url)
|
||||
repo.remove()
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Bootstrap HassIO."""
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
|
||||
import voluptuous as vol
|
||||
@ -60,13 +61,14 @@ class Config(object):
|
||||
if os.path.isfile(self._filename):
|
||||
try:
|
||||
self._data = read_json_file(self._filename)
|
||||
except OSError:
|
||||
except (OSError, json.JSONDecodeError):
|
||||
_LOGGER.warning("Can't read %s", self._filename)
|
||||
self._data = {}
|
||||
|
||||
def save(self):
|
||||
"""Store data to config file."""
|
||||
if not write_json_file(self._filename, self._data):
|
||||
_LOGGER.exception("Can't store config in %s", self._filename)
|
||||
_LOGGER.error("Can't store config in %s", self._filename)
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -228,5 +230,8 @@ class CoreConfig(Config):
|
||||
|
||||
def drop_addon_repository(self, repo):
|
||||
"""Remove a custom repository from list."""
|
||||
if self._data[ADDONS_CUSTOM_LIST].pop(repo, False):
|
||||
if repo not in self._data[ADDONS_CUSTOM_LIST]:
|
||||
return
|
||||
|
||||
self._data[ADDONS_CUSTOM_LIST].pop(repo)
|
||||
self.save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user