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() );