modules/admin-full: remove associated network for the wifi-iface as well if it would...
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 26 Oct 2011 22:52:18 +0000 (22:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 26 Oct 2011 22:52:18 +0000 (22:52 +0000)
modules/admin-full/luasrc/controller/admin/network.lua

index 87cc040ea7854756738e65f746d3edf3f758d3da..40856af2c28aec7638ae49fb4a3960a4e43d1c31 100644 (file)
@@ -198,14 +198,18 @@ end
 
 function wifi_delete(network)
        local ntm = require "luci.model.network".init()
-       local net = ntm:get_wifinet(network)
-
-       if net then
-               local dev = net:get_device()
+       local wnet = ntm:get_wifinet(network)
+       if wnet then
+               local dev = wnet:get_device()
+               local net = wnet:get_network()
                if dev then
                        luci.sys.call("env -i /sbin/wifi down %q" % dev:name())
                        ntm:del_wifinet(network)
                        ntm:commit("wireless")
+                       if net:is_empty() then
+                               ntm:del_network(net:name())
+                               ntm:commit("network")
+                       end
                        luci.sys.call("env -i /sbin/wifi up %q" % dev:name())
                end
        end