script missing policy
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -664,12 +664,29 @@ async fn repair(config:RepairConfig)->Result<(),RepairError>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All scripts should have exactly one policy
|
// All scripts should have exactly one policy
|
||||||
|
let mut script_missing_policy=Vec::new();
|
||||||
for script in &scripts{
|
for script in &scripts{
|
||||||
if !policy_from_hash.contains_key(script.Hash.as_str()){
|
if !policy_from_hash.contains_key(script.Hash.as_str()){
|
||||||
println!("Script {:?} has no policy!",script.ID);
|
println!("Script {:?} has no policy!",script.ID);
|
||||||
|
script_missing_policy.push(submissions_api::types::GetScriptRequest{
|
||||||
|
ScriptID:script.ID,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !script_missing_policy.is_empty(){
|
||||||
|
// ask to confirm delete scripts
|
||||||
|
print!("Delete {} orphaned scripts with no policy? [y/N]: ",script_missing_policy.len());
|
||||||
|
match ask_user_yes_no().map_err(RepairError::Io)?{
|
||||||
|
UserChoice::Yes=>{},
|
||||||
|
UserChoice::No=>return Ok(()),
|
||||||
|
}
|
||||||
|
|
||||||
|
futures::stream::iter(script_missing_policy).map(Ok).try_for_each_concurrent(REMOTE_CONCURRENCY,|request|{
|
||||||
|
api.delete_script(request)
|
||||||
|
}).await.map_err(RepairError::DeleteScript)?;
|
||||||
|
}
|
||||||
|
|
||||||
if !update_policies.is_empty(){
|
if !update_policies.is_empty(){
|
||||||
print!("Update {} policies? [y/N]: ",update_policies.len());
|
print!("Update {} policies? [y/N]: ",update_policies.len());
|
||||||
match ask_user_yes_no().map_err(RepairError::Io)?{
|
match ask_user_yes_no().map_err(RepairError::Io)?{
|
||||||
|
|||||||
Reference in New Issue
Block a user