Development
This commit is contained in:
parent
0cd648729e
commit
909030bace
1 changed files with 4 additions and 2 deletions
|
|
@ -276,6 +276,8 @@ def update_blocklist_hosts(data):
|
|||
|
||||
hosts_file = vlan_hosts_file(vlan)
|
||||
if not bl_names:
|
||||
if hosts_file.exists():
|
||||
hosts_file.write_text("")
|
||||
continue
|
||||
|
||||
if not changed.intersection(bl_names) and hosts_file.exists():
|
||||
|
|
@ -286,10 +288,10 @@ def update_blocklist_hosts(data):
|
|||
hosts_file.write_text(_build_merged_hosts(domains, bl_names))
|
||||
_log.info(f"VLAN '{vlan_name}': wrote {len(domains):,} domains from [{', '.join(sorted(bl_names))}]")
|
||||
|
||||
active_vlan_names = {v["name"] for v in data.get("vlans", [])}
|
||||
for f in shared.DNSMASQ_CONF_DIR.glob("for-*.hosts"):
|
||||
vlan_name = f.stem.removeprefix("for-")
|
||||
vlan = next((v for v in data.get("vlans", []) if v["name"] == vlan_name), None)
|
||||
if vlan is None or not vlan.get("use_blocklists"):
|
||||
if vlan_name not in active_vlan_names:
|
||||
f.unlink()
|
||||
_log.info(f"Removed stale hosts file: {f.name}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue