Fix controller not accepting old hosts.json format

Migrate the content of the hosts.json file before attempting to loading
it into the new datastore format.
This commit is contained in:
Hornwitser committed 2024-09-04 13:40:15 +02:00
1 parent 33c9542524
commit 7547a48fd6
1 file changed
+4 -4
+4 -4
View File
@@ -577,11 +577,11 @@ export default class Controller {
} }
static migrateHosts(rawJson: unknown[]): Static<typeof HostInfo.jsonSchema>[] { static migrateHosts(rawJson: unknown[]): Static<typeof HostInfo.jsonSchema>[] {
const serialized = rawJson as Static<typeof HostInfo.jsonSchema>[]; let serialized = rawJson as any;
// TODO: migrate remove after release. // migrate from pre alpha.19 format
if (serialized.length && !(serialized[0] instanceof Array)) { if (serialized.length && serialized[0] instanceof Array) {
return []; // Discard old format. serialized = serialized.map((e: any) => e[1]);
} }
return serialized; return serialized;