fix: convert dns_hosts from list to option format in UCI
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user