小红书导出构建前清掉上一次的产物
- build.rs 的 run 在启动项目脚本前删除 .export/xhs-minitool.zip(不存在则跳过,删不掉则 fail closed) - 避免 no-op 脚本靠上一轮残留的 zip 被判成功
This commit is contained in:
@@ -42,6 +42,23 @@ pub(crate) async fn run(
|
||||
}
|
||||
})?;
|
||||
|
||||
// 产物判据只看「文件非空」,所以先清掉上一次的 zip:脚本这次什么都没写时,残留的旧 zip 会
|
||||
// 让 no-op 脚本被判成功,用户上传的其实是上一轮的产物。删不掉(权限等)就 fail closed——
|
||||
// 留着旧产物继续判成功,比这次构建失败更糟。
|
||||
let artifact = artifact_path(root);
|
||||
match std::fs::remove_file(&artifact) {
|
||||
Ok(()) => {}
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(error) => {
|
||||
return Err(XHSMiniToolExportBuildError::ExportUnavailable(
|
||||
ExportUnavailable::new(format!(
|
||||
"清理上一次导出产物失败:{}:{error}",
|
||||
artifact.display()
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let result = run_project_verification_with_commit_at(
|
||||
root,
|
||||
SCRIPT_NAME,
|
||||
|
||||
Reference in New Issue
Block a user