From acdfb8ed7319be75b03e1a56febec469e3d51416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 24 Sep 2026 19:05:51 +0800 Subject: [PATCH] =?UTF-8?q?3D=20=E5=86=92=E7=83=9F=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=8A=8A=E4=BA=A7=E7=89=A9=E5=86=99=E5=88=B0=20target=20?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=90=BD=E5=88=B0?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs:产物落盘目录从「当前工作目录」改为 /tripo-smoke-artifacts,开始前建目录并打印路径;该目录本来就在入库排除范围内,根目录不会再攒出临时模型 - server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs:文件头文档同步改为说明新的产物落点 --- .../examples/tripo_generation_smoke.rs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs b/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs index fdb38fe8c..7bbee3a2e 100644 --- a/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs +++ b/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs @@ -9,10 +9,12 @@ //! ``` //! //! The example waits for each submitted task to finish, prints its mapped -//! output, and writes the downloaded model into the current directory. The -//! SDK poller is used only here and is not exposed by `platform-tripo`. +//! output, and writes the downloaded model into +//! `/tripo-smoke-artifacts` so a smoke run never leaves +//! tens-of-MB models inside the repository tree. The SDK poller is used only +//! here and is not exposed by `platform-tripo`. -use std::{env, time::Duration}; +use std::{env, path::PathBuf, time::Duration}; use platform_tripo::{TripoImageInput, TripoProviderClient}; use shared_contracts::model3d::{ @@ -31,6 +33,14 @@ const SAMPLE_IMAGE_URL: &str = "https://www.rustacean.net/assets/rustacean-flat- /// 冒烟脚本单次允许的产物体积上限,与 api-server 的口径一致(512 MiB)。 const SMOKE_MAX_ARTIFACT_BYTES: u64 = 512 * 1024 * 1024; +/// 产物落盘目录:固定在 cargo 的 target 目录下(`server-rs/target`), +/// 那里本来就不入库,示例也就不会在仓库里留下几十 MB 的临时模型。 +fn artifact_output_dir() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../target") + .join("tripo-smoke-artifacts") +} + #[tokio::main] async fn main() -> Result<(), Box> { let api_key = required_env("TRIPO_API_KEY")?; @@ -140,6 +150,10 @@ async fn main() -> Result<(), Box> { .await?; println!("multiview_to_model task_id={}", multiview.task_id); + let output_dir = artifact_output_dir(); + tokio::fs::create_dir_all(&output_dir).await?; + println!("artifact output dir={}", output_dir.display()); + for (name, handle) in [ ("text_to_model", text), ("image_to_model", image), @@ -198,11 +212,12 @@ async fn main() -> Result<(), Box> { } }; let filename = artifact.filename(name); - let mut file = File::create(&filename).await?; + let path = output_dir.join(&filename); + let mut file = File::create(&path).await?; file.write_all(&artifact.bytes).await?; println!( "{name} artifact={} bytes={} url={}", - filename, + path.display(), artifact.bytes.len(), artifact.url.redacted() );