fix: convert dns_hosts from list to option format in UCI

This commit is contained in:
Dushnilin
2026-08-01 22:41:05 +03:00
parent 7345515902
commit 336db69429
6 changed files with 53 additions and 16 deletions
+25 -1
View File
@@ -1285,10 +1285,34 @@ function migrate_http_connection_urls(ctx) {
}
}
function migrate_dns_hosts_to_option(ctx) {
let raw = object_or_empty(ctx.model.settings)["dns_hosts"];
if (raw == null)
return;
if (type(raw) != "array")
return;
let entries = [];
for (let value in raw) {
value = as_string(value);
if (value != "")
push(entries, value);
}
if (length(entries) == 0) {
delete_option(ctx, ctx.model.settings, "dns_hosts");
return;
}
set_option(ctx, ctx.model.settings, "dns_hosts", join("\n", entries));
}
const MIGRATIONS = [
{ id: "interface_sections", run: migrate_interface_sections },
{ id: "enable_component_checks", run: migrate_enable_component_checks },
{ id: "http_connection_urls", run: migrate_http_connection_urls }
{ id: "http_connection_urls", run: migrate_http_connection_urls },
{ id: "dns_hosts_to_option", run: migrate_dns_hosts_to_option }
];
function apply_migrations(ctx) {