fix: stop puzzle covers writing to public path
This commit is contained in:
@@ -683,8 +683,10 @@ pub fn build_generated_candidates(
|
||||
let candidate_id = format!("{session_id}-candidate-{}", index + 1);
|
||||
PuzzleGeneratedImageCandidate {
|
||||
candidate_id: candidate_id.clone(),
|
||||
// 拼图候选图的正式持久化由 api-server 上传 OSS;这里仅保留 reducer
|
||||
// 单测/保底路径构造,前缀必须与 OSS 兼容路由一致,不能再指向 public 目录。
|
||||
image_src: format!(
|
||||
"/generated-puzzle-covers/{session_id}/{candidate_seed}/cover.svg"
|
||||
"/generated-puzzle-assets/{session_id}/{candidate_seed}/cover.svg"
|
||||
),
|
||||
asset_id: format!("puzzle-cover-{candidate_seed}"),
|
||||
prompt: prompt.clone(),
|
||||
@@ -1543,6 +1545,21 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generated_candidates_use_oss_compatible_prefix() {
|
||||
let anchor_pack = infer_anchor_pack("雨夜猫咪", Some("雨夜猫咪"));
|
||||
let draft = compile_result_draft(&anchor_pack, &[]);
|
||||
let candidates = build_generated_candidates("session-1", None, &draft, 2, 1_000)
|
||||
.expect("candidates should build");
|
||||
|
||||
assert_eq!(candidates.len(), 2);
|
||||
assert!(candidates[0]
|
||||
.image_src
|
||||
.starts_with("/generated-puzzle-assets/session-1/"));
|
||||
let legacy_public_prefix = ["generated-puzzle", "covers"].join("-");
|
||||
assert!(!candidates[0].image_src.contains(&legacy_public_prefix));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tag_similarity_score_uses_jaccard() {
|
||||
let score = tag_similarity_score(
|
||||
|
||||
Reference in New Issue
Block a user