mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix offline db migration support (#21452)
* Fix offline db migration support * Add error handling
This commit is contained in:
parent
87ba0e73dd
commit
79618ce114
@ -200,24 +200,26 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async checkDataBaseMigration() {
|
protected async checkDataBaseMigration() {
|
||||||
if (this.hass?.config?.components.includes("recorder")) {
|
let recorderInfoProm: Promise<RecorderInfo> | undefined;
|
||||||
let recorderInfoProm: Promise<RecorderInfo> | undefined;
|
const preloadWindow = window as WindowWithPreloads;
|
||||||
const preloadWindow = window as WindowWithPreloads;
|
// On first load, we speed up loading page by having recorderInfoProm ready
|
||||||
// On first load, we speed up loading page by having recorderInfoProm ready
|
if (preloadWindow.recorderInfoProm) {
|
||||||
if (preloadWindow.recorderInfoProm) {
|
recorderInfoProm = preloadWindow.recorderInfoProm;
|
||||||
recorderInfoProm = preloadWindow.recorderInfoProm;
|
preloadWindow.recorderInfoProm = undefined;
|
||||||
preloadWindow.recorderInfoProm = undefined;
|
}
|
||||||
}
|
const info = await (
|
||||||
const info = await (recorderInfoProm ||
|
recorderInfoProm || getRecorderInfo(this.hass!.connection)
|
||||||
getRecorderInfo(this.hass.connection));
|
).catch((err) => {
|
||||||
this._databaseMigration =
|
// If the command failed with code unknown_command, recorder is not enabled,
|
||||||
info.migration_in_progress && !info.migration_is_live;
|
// otherwise re-throw the error
|
||||||
if (this._databaseMigration) {
|
if (err.code !== "unknown_command") throw err;
|
||||||
// check every 5 seconds if the migration is done
|
return { migration_in_progress: false, migration_is_live: false };
|
||||||
setTimeout(() => this.checkDataBaseMigration(), 5000);
|
});
|
||||||
}
|
this._databaseMigration =
|
||||||
} else {
|
info.migration_in_progress && !info.migration_is_live;
|
||||||
this._databaseMigration = false;
|
if (this._databaseMigration) {
|
||||||
|
// check every 5 seconds if the migration is done
|
||||||
|
setTimeout(() => this.checkDataBaseMigration(), 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user