feat(export-tracker): 增强导出任务跟踪功能 (#1958)
- 添加了对数据库导出、SQL 文件导出和数据传输任务的支持 - 引入了新的状态和错误处理机制 - 实现了任务的重叠检查,防止同时进行相同目标表的数据传输 - 更新了 API 调用以支持新的任务类型 - 增加了相应的国际化文本 - 添加了单元测试以确保新功能的正确性
This commit is contained in:
15 files changed
+838
-208
No files matched your search
@@ -94,6 +94,7 @@ pub async fn start_transfer(
|
||||
log::warn!("[transfer] failed to sort tables by FK dependency, using original order: {e}");
|
||||
tables
|
||||
});
|
||||
let mut failed_tables: Vec<String> = Vec::new();
|
||||
for (i, table) in tables.iter().enumerate() {
|
||||
if transfer::is_cancelled(&req.transfer_id).await {
|
||||
let progress = transfer::TransferProgress {
|
||||
@@ -153,6 +154,7 @@ pub async fn start_transfer(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
failed_tables.push(table.clone());
|
||||
let progress = transfer::TransferProgress {
|
||||
transfer_id: req.transfer_id.clone(),
|
||||
table: table.clone(),
|
||||
@@ -178,8 +180,16 @@ pub async fn start_transfer(
|
||||
total_tables: tables.len(),
|
||||
rows_transferred: 0,
|
||||
total_rows: None,
|
||||
status: TransferStatus::Done,
|
||||
error: None,
|
||||
status: if failed_tables.is_empty() { TransferStatus::Done } else { TransferStatus::Error },
|
||||
error: if failed_tables.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(format!(
|
||||
"{} table(s) failed: {}",
|
||||
failed_tables.len(),
|
||||
failed_tables.iter().take(5).cloned().collect::<Vec<_>>().join(", ")
|
||||
))
|
||||
},
|
||||
};
|
||||
if let Ok(json) = serde_json::to_string(&done) {
|
||||
let _ = tx.send(json);
|
||||
|
||||
Reference in new issue
Block a user