diff --git a/server-rs/crates/platform-tripo/src/common/types.rs b/server-rs/crates/platform-tripo/src/common/types.rs index a2cc19745..a1ea065e0 100644 --- a/server-rs/crates/platform-tripo/src/common/types.rs +++ b/server-rs/crates/platform-tripo/src/common/types.rs @@ -155,7 +155,6 @@ pub(crate) struct TripoDownloadedArtifact { /// 与 [`TripoDownloadedArtifact`] 的区别是「读完了」:body 中途失败会被下载入口整体重下, /// 因此拿到这个值就代表这次读取是完整的。(几十 MB 的产物当前一次性读进内存,api-server /// 侧同样如此;未来接 OSS 流式 / 分片上传时再回到流式句柄。) -#[derive(Debug)] pub struct TripoArtifactBytes { pub url: TripoUrl, pub content_type: Option, @@ -164,6 +163,19 @@ pub struct TripoArtifactBytes { pub bytes: Vec, } +impl fmt::Debug for TripoArtifactBytes { + /// 只打印元数据与字节数:`bytes` 是几十 MB 级的产物,派生的 `Debug` 会把每个字节 + /// 写成十进制文本,一次 `{artifact:?}` 就能刷出几百 MB 日志。 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("TripoArtifactBytes") + .field("url", &self.url) + .field("content_type", &self.content_type) + .field("content_length", &self.content_length) + .field("bytes_len", &self.bytes.len()) + .finish() + } +} + impl TripoDownloadedArtifact { pub(crate) fn new( task_id: String, @@ -378,4 +390,18 @@ mod tests { "artifact.glb" ); } + + #[test] + fn artifact_debug_reports_metadata_instead_of_the_payload() { + let artifact = TripoArtifactBytes { + url: artifact_url("/a.glb"), + content_type: Some("model/gltf-binary".to_string()), + content_length: Some(8), + bytes: vec![171; 8], + }; + + let debug = format!("{artifact:?}"); + assert!(debug.contains("bytes_len: 8"), "{debug}"); + assert!(!debug.contains("171"), "产物字节不能进 Debug 输出:{debug}"); + } }