fix(backups): сверять сервер и файл подтверждения импорта

This commit is contained in:
Denozordec committed 2026-10-01 16:18:37 +07:00
1 parent af86d2c3cd
commit 99ff5aebaf
11 files changed
+51 -13

No files matched your search

+4 -2
View File
@@ -42,8 +42,10 @@ export async function deleteBackup(baseUrl: string, id: string, options?: Reques
const response = await requestBlob(baseUrl, "/api/backups/" + encodeURIComponent(id), backupOptions({ ...options, method: "DELETE" }))
if (response.status !== 204) throw new Error("Удаление резервной копии не подтверждено: ожидается HTTP 204")
}
export async function restoreBackup(baseUrl: string, id: string, options?: RequestInit) {
return restoreBackupResponseSchema.parse(await backupJson(baseUrl, "/api/backups/" + encodeURIComponent(id) + "/restore", { ...options, method: "POST" }))
export async function restoreBackup(baseUrl: string, id: string, options?: RequestInit, expectedServerId?: number) {
const result = restoreBackupResponseSchema.parse(await backupJson(baseUrl, "/api/backups/" + encodeURIComponent(id) + "/restore", { ...options, method: "POST" }))
if (result.backupId !== id || (expectedServerId !== undefined && result.serverId !== expectedServerId)) throw new Error("Ответ восстановления относится к другой резервной копии или серверу")
return result
}
export async function getBackupScheduleSettings(baseUrl: string, options?: RequestInit) {
return backupScheduleSettingsDtoSchema.parse(await backupJson(baseUrl, "/api/backups/schedule", { ...options, method: "GET" }))