mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-09 06:23:29 +08:00
🐛 fix(data-sync): 修复已保存连接同步时未恢复密文
- Data Sync 分析/预览/同步入口统一恢复源库和目标库连接密文 - 避免已保存 PostgreSQL 连接因空密码触发 28P01 - 保留前端选择的源/目标数据库覆盖值 - 增加保存连接密文恢复回归测试 Refs #413
This commit is contained in:
@@ -11,6 +11,21 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
func (a *App) resolveDataSyncConfigSecrets(config sync.SyncConfig) (sync.SyncConfig, error) {
|
||||
resolved := config
|
||||
sourceConfig, err := a.resolveConnectionSecrets(config.SourceConfig)
|
||||
if err != nil {
|
||||
return resolved, fmt.Errorf("恢复源数据库连接密文失败: %w", err)
|
||||
}
|
||||
targetConfig, err := a.resolveConnectionSecrets(config.TargetConfig)
|
||||
if err != nil {
|
||||
return resolved, fmt.Errorf("恢复目标数据库连接密文失败: %w", err)
|
||||
}
|
||||
resolved.SourceConfig = sourceConfig
|
||||
resolved.TargetConfig = targetConfig
|
||||
return resolved, nil
|
||||
}
|
||||
|
||||
// DataSync executes a data synchronization task
|
||||
func (a *App) DataSync(config sync.SyncConfig) sync.SyncResult {
|
||||
jobID := strings.TrimSpace(config.JobID)
|
||||
@@ -33,8 +48,22 @@ func (a *App) DataSync(config sync.SyncConfig) sync.SyncResult {
|
||||
"total": len(config.Tables),
|
||||
})
|
||||
|
||||
resolvedConfig, err := a.resolveDataSyncConfigSecrets(config)
|
||||
if err != nil {
|
||||
res := sync.SyncResult{
|
||||
Success: false,
|
||||
Message: err.Error(),
|
||||
Logs: []string{err.Error()},
|
||||
}
|
||||
runtime.EventsEmit(a.ctx, sync.EventSyncDone, map[string]any{
|
||||
"jobId": jobID,
|
||||
"result": res,
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
engine := sync.NewSyncEngine(reporter)
|
||||
res := engine.RunSync(config)
|
||||
res := engine.RunSync(resolvedConfig)
|
||||
|
||||
runtime.EventsEmit(a.ctx, sync.EventSyncDone, map[string]any{
|
||||
"jobId": jobID,
|
||||
@@ -67,8 +96,19 @@ func (a *App) DataSyncAnalyze(config sync.SyncConfig) connection.QueryResult {
|
||||
"type": "analyze",
|
||||
})
|
||||
|
||||
resolvedConfig, err := a.resolveDataSyncConfigSecrets(config)
|
||||
if err != nil {
|
||||
res := sync.SyncResult{Success: false, Message: err.Error(), Logs: []string{err.Error()}}
|
||||
runtime.EventsEmit(a.ctx, sync.EventSyncDone, map[string]any{
|
||||
"jobId": jobID,
|
||||
"result": res,
|
||||
"type": "analyze",
|
||||
})
|
||||
return connection.QueryResult{Success: false, Message: err.Error(), Data: res}
|
||||
}
|
||||
|
||||
engine := sync.NewSyncEngine(reporter)
|
||||
res := engine.Analyze(config)
|
||||
res := engine.Analyze(resolvedConfig)
|
||||
|
||||
runtime.EventsEmit(a.ctx, sync.EventSyncDone, map[string]any{
|
||||
"jobId": jobID,
|
||||
@@ -90,8 +130,13 @@ func (a *App) DataSyncPreview(config sync.SyncConfig, tableName string, limit in
|
||||
config.JobID = jobID
|
||||
}
|
||||
|
||||
resolvedConfig, err := a.resolveDataSyncConfigSecrets(config)
|
||||
if err != nil {
|
||||
return connection.QueryResult{Success: false, Message: err.Error()}
|
||||
}
|
||||
|
||||
engine := sync.NewSyncEngine(sync.Reporter{})
|
||||
preview, err := engine.Preview(config, tableName, limit)
|
||||
preview, err := engine.Preview(resolvedConfig, tableName, limit)
|
||||
if err != nil {
|
||||
return connection.QueryResult{Success: false, Message: err.Error()}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user