diff --git a/src/data/backup.ts b/src/data/backup.ts index 5133787f034f..d1299a2a7e75 100644 --- a/src/data/backup.ts +++ b/src/data/backup.ts @@ -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";