MCPcopy Create free account
hub / github.com/Prejudice-Studio/Twilight / postgresTargetReadyMap

Function postgresTargetReadyMap

internal/api/database_admin.go:341–352  ·  view source on GitHub ↗
(driver string, status store.PostgresTargetStatus)

Source from the content-addressed store, hash-verified

339 preMigration, backupErr := a.store().BackupWithNote(a.cfg().DatabaseBackupDir, "数据库迁移前保护性备份")
340 if backupErr != nil {
341 failWithCode(w, http.StatusInternalServerError, ErrDBRestoreBackupFail, "迁移前备份失败")
342 return
343 }
344 if err := os.MkdirAll(filepath.Dir(targetPath), 0o700); err != nil {
345 failWithCode(w, http.StatusInternalServerError, ErrDBStateFileMkdirBad, "创建数据库目录失败")
346 return
347 }
348 // 走 store.WriteFileAtomicSync:tmp + fsync(file) + rename + fsync(dir),
349 // 与 saveLocked / BackupWithNote 共用一份原子写盘语义,掉电也不会留下
350 // 半截 state 文件让前端显示"迁移成功"但磁盘上根本没有内容。
351 if err := store.WriteFileAtomicSync(targetPath, snapshot, 0o600); err != nil {
352 failWithCode(w, http.StatusInternalServerError, ErrDBStateFileWriteBad, "写入状态文件失败")
353 return
354 }
355 summary := a.databaseMigrationSummary(store.BackendJSON, state, dryRun, snapshotBytes, targetReady)

Callers 1

handleDatabaseMigrateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected