Comparison

plugins/mod_admin_telnet.lua @ 9332:048389a9bbd4

mod_admin_telnet: Split out sort function for clarity
author Matthew Wild <mwild1@gmail.com>
date Fri, 21 Sep 2018 14:37:47 +0100
parent 9330:36badabc85ce
child 9391:4001eb3f465a
comparison
equal deleted inserted replaced
9331:2f634cc02eac 9332:048389a9bbd4
402 end 402 end
403 end 403 end
404 return ok, (ok and "Module unloaded from "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); 404 return ok, (ok and "Module unloaded from "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err));
405 end 405 end
406 406
407 local function _sort_hosts(a, b)
408 if a == "*" then return true
409 elseif b == "*" then return false
410 else return a < b; end
411 end
412
407 function def_env.module:reload(name, hosts) 413 function def_env.module:reload(name, hosts)
408 hosts = array.collect(get_hosts_set(hosts, name)):sort(function (a, b) 414 hosts = array.collect(get_hosts_set(hosts, name)):sort(_sort_hosts)
409 if a == "*" then return true
410 elseif b == "*" then return false
411 else return a < b; end
412 end);
413 415
414 -- Reload the module for each host 416 -- Reload the module for each host
415 local ok, err, count = true, nil, 0; 417 local ok, err, count = true, nil, 0;
416 for _, host in ipairs(hosts) do 418 for _, host in ipairs(hosts) do
417 if modulemanager.is_loaded(host, name) then 419 if modulemanager.is_loaded(host, name) then