mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 07:33:18 +02:00
Fix virtual printer config changes ignored on running instances
sync_from_db() skipped VPs already in self._instances without checking if their config had changed. Mode, model, access code, bind IP, remote interface IP, and target printer changes were silently ignored until manual toggle off/on or full restart. Now detects config drift and restarts affected instances.
This commit is contained in:
@@ -626,6 +626,30 @@ class VirtualPrinterManager:
|
||||
if printer:
|
||||
proxy_ips[pvp.id] = (printer.ip_address, printer.serial_number)
|
||||
|
||||
# Detect config changes on running instances and restart if needed
|
||||
for vp in enabled_vps:
|
||||
instance = self._instances.get(vp.id)
|
||||
if not instance:
|
||||
continue
|
||||
|
||||
changed = (
|
||||
instance.mode != vp.mode
|
||||
or instance.model != (vp.model or DEFAULT_VIRTUAL_PRINTER_MODEL)
|
||||
or instance.access_code != (vp.access_code or "")
|
||||
or instance.bind_ip != (vp.bind_ip or "")
|
||||
or instance.remote_interface_ip != (vp.remote_interface_ip or "")
|
||||
or instance.target_printer_id != vp.target_printer_id
|
||||
)
|
||||
|
||||
if changed:
|
||||
logger.info(
|
||||
"VP %s config changed (mode: %s→%s), restarting",
|
||||
instance.name,
|
||||
instance.mode,
|
||||
vp.mode,
|
||||
)
|
||||
await self.remove_instance(vp.id)
|
||||
|
||||
# Start instances for all enabled VPs (skip already running)
|
||||
for vp in enabled_vps:
|
||||
if vp.id in self._instances:
|
||||
|
||||
Reference in New Issue
Block a user