cli (profile): fix profile check for create and delete:

When checking existing profiles with `bridge.profiles_list_get`, all profiles have to be
retrieved, including components.
This commit is contained in:
Goffi 2026-03-30 12:05:13 +02:00
commit 685193602e

View file

@ -118,7 +118,7 @@ class ProfileCreate(base.CommandBase):
async def start(self):
"""Create a new profile"""
if self.args.profile in await self.host.bridge.profiles_list_get():
if self.args.profile in await self.host.bridge.profiles_list_get(True, True):
self.disp(f"Profile {self.args.profile} already exists.", error=True)
self.host.quit(C.EXIT_BRIDGE_ERROR)
try:
@ -189,7 +189,7 @@ class ProfileDelete(base.CommandBase):
)
async def start(self):
if self.args.profile not in await self.host.bridge.profiles_list_get():
if self.args.profile not in await self.host.bridge.profiles_list_get(True, True):
log.error(f"Profile {self.args.profile} doesn't exist.")
self.host.quit(C.EXIT_NOT_FOUND)
if not self.args.force:
@ -197,8 +197,13 @@ class ProfileDelete(base.CommandBase):
cancel_message = "Profile deletion cancelled"
await self.host.confirm_or_quit(message, cancel_message)
await self.host.bridge.profile_delete_async(self.args.profile)
self.host.quit()
try:
await self.host.bridge.profile_delete_async(self.args.profile)
except Exception as e:
self.disp(f"can't delete profile: {e}", error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
else:
self.host.quit()
class ProfileInfo(base.CommandBase):