Fix add-on store reset

Make sure that add-on store resets do not delete the root folder. This
is important so that successive reset attempts do not fail (the
directory passed to `remove_folder` must exist, otherwise find fails
with an non-zero exit code).

While at it, handle find errors properly and report errors as critical.
This commit is contained in:
Stefan Agner 2025-02-25 08:57:11 +01:00
parent 802ee25a8b
commit da8c6cf111
No known key found for this signature in database
GPG Key ID: AE01353D1E44747D
2 changed files with 5 additions and 3 deletions

View File

@ -1,5 +1,6 @@
"""Helpers to check and fix issues with free space.""" """Helpers to check and fix issues with free space."""
from functools import partial
import logging import logging
from ...coresys import CoreSys from ...coresys import CoreSys
@ -40,7 +41,9 @@ class FixupStoreExecuteReset(FixupBase):
_LOGGER.warning("Can't find store %s for fixup", reference) _LOGGER.warning("Can't find store %s for fixup", reference)
return return
await self.sys_run_in_executor(remove_folder, repository.git.path) await self.sys_run_in_executor(
partial(remove_folder, folder=repository.git.path, content_only=True)
)
# Load data again # Load data again
try: try:

View File

@ -106,8 +106,7 @@ def remove_folder(
except OSError as err: except OSError as err:
_LOGGER.exception("Can't remove folder %s: %s", folder, err) _LOGGER.exception("Can't remove folder %s: %s", folder, err)
except subprocess.CalledProcessError as procerr: except subprocess.CalledProcessError as procerr:
_LOGGER.error("Can't remove folder %s: %s", folder, procerr.stderr.strip()) _LOGGER.critical("Can't remove folder %s: %s", folder, procerr.stderr.strip())
raise procerr
def remove_folder_with_excludes( def remove_folder_with_excludes(