mirror of https://github.com/jackwener/wx-cli.git
fix(daemon): drop redundant `ok` from extract payload (collides with Response.ok)
Response 用 #[serde(flatten)] 把 q_* 返回的 Value 拼到 `{ok, error, ...data}`
里,q_extract 里再塞一个 `"ok": true` 就会在 wire 上写出两个同名 key,CLI
端 `serde_json::from_str::<Response>` 直接报「duplicate field `ok`」,对外
表现是「extract 失败 / 解析 daemon 响应失败」,但 daemon 实际已经把图解出来
了。其他 q_* 都没塞 ok(biz_articles / sessions / history 等),保持一致。
pull/57/head
parent
2d88c9542d
commit
7feacc6371
|
|
@ -3549,9 +3549,11 @@ pub async fn q_extract(
|
||||||
std::fs::write(&output_path2, &decoded.data)
|
std::fs::write(&output_path2, &decoded.data)
|
||||||
.with_context(|| format!("写出文件失败:{}", output_path2.display()))?;
|
.with_context(|| format!("写出文件失败:{}", output_path2.display()))?;
|
||||||
|
|
||||||
|
// 注意:不要在这里塞 `ok: true`。dispatch 会用 Response::ok(v) 包一层,
|
||||||
|
// Response 的 `data: Value` 字段是 #[serde(flatten)] 写出的,本 payload
|
||||||
|
// 的 `ok` 会和 Response 自带的 `ok` 在线上拼成两个同名 key,CLI 反序列化时
|
||||||
|
// serde_json 直接报 "duplicate field",业务请求看上去像 daemon 解析失败。
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"ok": true,
|
|
||||||
"attachment_id": attachment_id_str(&id_for_task)?,
|
|
||||||
"kind": id_for_task.kind.as_str(),
|
"kind": id_for_task.kind.as_str(),
|
||||||
"md5": resolved.md5,
|
"md5": resolved.md5,
|
||||||
"dat_path": resolved.dat_path.display().to_string(),
|
"dat_path": resolved.dat_path.display().to_string(),
|
||||||
|
|
@ -3593,10 +3595,6 @@ fn parse_attachment_kinds(
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attachment_id_str(id: &crate::attachment::AttachmentId) -> Result<String> {
|
|
||||||
id.encode()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod biz_tests {
|
mod biz_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue