From 0859fba431e14d8f58d5a032149171049ea20667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Tr=C3=A1vn=C3=ADk?= Date: Tue, 30 Dec 2025 14:33:53 +0100 Subject: [PATCH] feat: enhance repository export by adding isExistingRepository flag and computing path for local repos --- .../lifecycle/config-export.controller.ts | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/server/modules/lifecycle/config-export.controller.ts b/app/server/modules/lifecycle/config-export.controller.ts index 9df9d3c3..58ecb6ab 100644 --- a/app/server/modules/lifecycle/config-export.controller.ts +++ b/app/server/modules/lifecycle/config-export.controller.ts @@ -9,7 +9,7 @@ import { } from "../../db/schema"; import { db } from "../../db/db"; import { logger } from "../../utils/logger"; -import { RESTIC_PASS_FILE } from "../../core/constants"; +import { RESTIC_PASS_FILE, REPOSITORY_BASE } from "../../core/constants"; import { cryptoUtils } from "../../utils/crypto"; import { authService } from "../auth/auth.service"; import { volumeService } from "../volumes/volume.service"; @@ -230,14 +230,22 @@ export const configExportController = new Hono() exportEntities(notifications, params), ]); - // Add isExistingRepository flag to all repository configs for import compatibility - const exportRepositories = exportRepositoriesRaw.map((repo) => ({ - ...repo, - config: - repo.config && typeof repo.config === "object" - ? { ...(repo.config as Record), isExistingRepository: true } - : repo.config, - })); + // Add isExistingRepository flag and path to all repository configs for import compatibility + const exportRepositories = exportRepositoriesRaw.map((repo) => { + if (!repo.config || typeof repo.config !== "object") { + return repo; + } + + const config = repo.config as Record; + const updatedConfig: Record = { ...config, isExistingRepository: true }; + + // For local repos, compute and add the full path if not already present + if (config.backend === "local" && !config.path && typeof config.name === "string") { + updatedConfig.path = `${REPOSITORY_BASE}/${config.name}`; + } + + return { ...repo, config: updatedConfig }; + }); let recoveryKey: string | undefined; if (includeRecoveryKey) {