machine: improve multi-instance validation
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
8f444a908e
commit
974b37dad8
|
@ -1299,7 +1299,7 @@ class InstallValidator:
|
|||
if unit != "moonraker":
|
||||
logging.info(f"Custom service file detected: {unit}")
|
||||
# Not using he default unit name
|
||||
if app_args["is_default_data_path"]:
|
||||
if app_args["is_default_data_path"] and self.data_path_valid:
|
||||
# No datapath set, create a new, unique data path
|
||||
df = f"~/{unit}_data"
|
||||
match = re.match(r"moonraker[-_]?(\d+)", unit)
|
||||
|
@ -1314,7 +1314,10 @@ class InstallValidator:
|
|||
)
|
||||
|
||||
# If the current path is bare we can remove it
|
||||
if self._check_path_bare(self.data_path):
|
||||
if (
|
||||
self.data_path.exists() and
|
||||
self._check_path_bare(self.data_path)
|
||||
):
|
||||
shutil.rmtree(self.data_path)
|
||||
self.data_path = new_dp
|
||||
if not self.data_path.exists():
|
||||
|
@ -1409,6 +1412,8 @@ class InstallValidator:
|
|||
|
||||
def _check_path_bare(self, path: pathlib.Path) -> bool:
|
||||
empty: bool = True
|
||||
if not path.exists():
|
||||
return True
|
||||
for item in path.iterdir():
|
||||
if (
|
||||
item.is_file() or
|
||||
|
@ -1417,7 +1422,7 @@ class InstallValidator:
|
|||
):
|
||||
empty = False
|
||||
break
|
||||
if next(item.iterdir(), None) is not None:
|
||||
if item.is_dir() and next(item.iterdir(), None) is not None:
|
||||
empty = False
|
||||
break
|
||||
return empty
|
||||
|
@ -1659,9 +1664,10 @@ class InstallValidator:
|
|||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception as e:
|
||||
logging.exception(f"{name} validation failed")
|
||||
raise self.server.error(
|
||||
f"{name} validation failed with error:\n{e}", 500
|
||||
) from e
|
||||
f"{name} validation failed", 500
|
||||
) from None
|
||||
await self.remove_announcement()
|
||||
db: MoonrakerDatabase = self.server.lookup_component("database")
|
||||
await db.insert_item(
|
||||
|
|
Loading…
Reference in New Issue