feat: enhance repository export by adding isExistingRepository flag and computing path for local repos
This commit is contained in:
parent
4090d5caa6
commit
0859fba431
1 changed files with 17 additions and 9 deletions
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from "../../db/schema";
|
} from "../../db/schema";
|
||||||
import { db } from "../../db/db";
|
import { db } from "../../db/db";
|
||||||
import { logger } from "../../utils/logger";
|
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 { cryptoUtils } from "../../utils/crypto";
|
||||||
import { authService } from "../auth/auth.service";
|
import { authService } from "../auth/auth.service";
|
||||||
import { volumeService } from "../volumes/volume.service";
|
import { volumeService } from "../volumes/volume.service";
|
||||||
|
|
@ -230,14 +230,22 @@ export const configExportController = new Hono()
|
||||||
exportEntities(notifications, params),
|
exportEntities(notifications, params),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Add isExistingRepository flag to all repository configs for import compatibility
|
// Add isExistingRepository flag and path to all repository configs for import compatibility
|
||||||
const exportRepositories = exportRepositoriesRaw.map((repo) => ({
|
const exportRepositories = exportRepositoriesRaw.map((repo) => {
|
||||||
...repo,
|
if (!repo.config || typeof repo.config !== "object") {
|
||||||
config:
|
return repo;
|
||||||
repo.config && typeof repo.config === "object"
|
}
|
||||||
? { ...(repo.config as Record<string, unknown>), isExistingRepository: true }
|
|
||||||
: repo.config,
|
const config = repo.config as Record<string, unknown>;
|
||||||
}));
|
const updatedConfig: Record<string, unknown> = { ...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;
|
let recoveryKey: string | undefined;
|
||||||
if (includeRecoveryKey) {
|
if (includeRecoveryKey) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue