mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Fix preferred agent for backup download (#23659)
This commit is contained in:
parent
b02d0e58b1
commit
5e7f356707
@ -1,16 +1,16 @@
|
||||
import { setHours, setMinutes } from "date-fns";
|
||||
import type { HassConfig } from "home-assistant-js-websocket";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { formatTime } from "../common/datetime/format_time";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import { domainToName } from "./integration";
|
||||
import type { FrontendLocaleData } from "./translation";
|
||||
import {
|
||||
formatDateTime,
|
||||
formatDateTimeNumeric,
|
||||
} from "../common/datetime/format_date_time";
|
||||
import { formatTime } from "../common/datetime/format_time";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import { fileDownload } from "../util/file_download";
|
||||
import { domainToName } from "./integration";
|
||||
import type { FrontendLocaleData } from "./translation";
|
||||
|
||||
export const enum BackupScheduleState {
|
||||
NEVER = "never",
|
||||
@ -217,10 +217,16 @@ export const uploadBackup = async (
|
||||
};
|
||||
|
||||
export const getPreferredAgentForDownload = (agents: string[]) => {
|
||||
const localAgents = agents.filter(
|
||||
(agent) => agent.split(".")[0] === "backup"
|
||||
);
|
||||
return localAgents[0] || agents[0];
|
||||
const localAgent = agents.find(isLocalAgent);
|
||||
if (localAgent) {
|
||||
return localAgent;
|
||||
}
|
||||
const networkMountAgent = agents.find(isNetworkMountAgent);
|
||||
if (networkMountAgent) {
|
||||
return networkMountAgent;
|
||||
}
|
||||
|
||||
return agents[0];
|
||||
};
|
||||
|
||||
export const CORE_LOCAL_AGENT = "backup.local";
|
||||
|
Loading…
x
Reference in New Issue
Block a user