Commit 22fd4292 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

default-routes.lua: reevaluate current profile only for its own routes

Only check the current active profile when some routes changed that are part of
the profile. If some other route changed, just ignore it.
parent a452250b
Pipeline #464670 passed with stages
in 3 minutes and 34 seconds
......@@ -352,6 +352,12 @@ function handleDevice(device)
local dev_info = dev_infos[device["bound-id"]]
local new_route_infos = {}
local avail_routes_changed = false
local profile = nil
-- get current profile
for p in device:iterate_params("Profile") do
profile = parseParam(p, "Profile")
end
-- look at all the routes and update/reset cached information
for p in device:iterate_params("EnumRoute") do
......@@ -370,7 +376,9 @@ function handleDevice(device)
Log.info(device, "route " .. route.name .. " available changed " ..
route_info.available .. " -> " .. route.available)
route_info.available = route.available
avail_routes_changed = true
if profile and arrayContains(route.profiles, profile.index) then
avail_routes_changed = true
end
end
route_info.prev_active = route_info.active
route_info.active = false
......@@ -419,23 +427,20 @@ function handleDevice(device)
::skip_route::
end
-- now get the profile and restore routes for it
for p in device:iterate_params("Profile") do
local profile = parseParam(p, "Profile")
if profile then
local profile_changed = (dev_info.active_profile ~= profile.index)
-- if the profile changed, restore routes for that profile
-- if any of the routes of the current profile changed in availability,
-- then try to select a new "best" route for each device and ignore
-- what was stored
if profile_changed or avail_routes_changed then
dev_info.active_profile = profile.index
restoreProfileRoutes(device, dev_info, profile, profile_changed)
end
saveProfile(dev_info, profile.name)
-- restore routes for profile
if profile then
local profile_changed = (dev_info.active_profile ~= profile.index)
-- if the profile changed, restore routes for that profile
-- if any of the routes of the current profile changed in availability,
-- then try to select a new "best" route for each device and ignore
-- what was stored
if profile_changed or avail_routes_changed then
dev_info.active_profile = profile.index
restoreProfileRoutes(device, dev_info, profile, profile_changed)
end
saveProfile(dev_info, profile.name)
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment