Handle corrupt store branch / ignore local reset on corruption (#2490)

* Handle corrupt store branch / ignore local reset on corruption

* Update data.py

* Update data.py
This commit is contained in:
Pascal Vizeli 2021-01-31 22:55:43 +01:00 committed by GitHub
parent b09aee7644
commit 17f62b6e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -18,6 +18,7 @@ from ..coresys import CoreSys, CoreSysAttributes
from ..exceptions import JsonFileError
from ..resolution.const import ContextType, IssueType, SuggestionType
from ..utils.json import read_json_file
from .const import StoreType
from .utils import extract_hash_from_path
from .validate import SCHEMA_REPOSITORY_CONFIG
@ -83,11 +84,14 @@ class StoreData(CoreSysAttributes):
if ".git" not in addon.parts
]
except OSError as err:
suggestion = None
if path.stem != StoreType.LOCAL:
suggestion = [SuggestionType.EXECUTE_RESET]
self.sys_resolution.create_issue(
IssueType.CORRUPT_REPOSITORY,
ContextType.STORE,
reference=path.stem,
suggestions=[SuggestionType.EXECUTE_RESET],
suggestions=suggestion,
)
_LOGGER.critical(
"Can't process %s because of Filesystem issues: %s", repository, err

View File

@ -147,9 +147,10 @@ class GitRepo(CoreSysAttributes):
async with self.lock:
_LOGGER.info("Update add-on %s repository", self.url)
branch = self.repo.active_branch.name
try:
branch = self.repo.active_branch.name
# Download data
await self.sys_run_in_executor(
ft.partial(
@ -182,6 +183,7 @@ class GitRepo(CoreSysAttributes):
git.InvalidGitRepositoryError,
git.NoSuchPathError,
git.GitCommandError,
ValueError,
) as err:
_LOGGER.error("Can't update %s repo: %s.", self.url, err)
self.sys_resolution.create_issue(