validation: skip upload if model validates as-is
This commit is contained in:
parent
5ed15a6847
commit
a844c4e90a
@ -175,7 +175,7 @@ impl crate::message_handler::MessageHandler{
|
||||
.await?;
|
||||
|
||||
// make the replacements
|
||||
let mut modified=true;
|
||||
let mut modified=false;
|
||||
for &script_ref in &script_refs{
|
||||
if let Some(script)=dom.get_by_ref_mut(script_ref){
|
||||
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get_mut("Source"){
|
||||
@ -211,10 +211,8 @@ impl crate::message_handler::MessageHandler{
|
||||
}
|
||||
}
|
||||
|
||||
println!("[Validator] Forcing model upload! modified=true");
|
||||
|
||||
// if the model was validated, the submission must be changed to use the modified model
|
||||
if modified{
|
||||
let (validated_model_id,validated_model_version)=if modified{
|
||||
// serialize model (slow!)
|
||||
let mut data=Vec::new();
|
||||
let &[map_ref]=dom.root().children()else{
|
||||
@ -223,7 +221,7 @@ impl crate::message_handler::MessageHandler{
|
||||
rbx_binary::to_writer(&mut data,&dom,&[map_ref]).map_err(Error::ModelFileEncode)?;
|
||||
|
||||
// upload a model lol
|
||||
let model_id=if let Some(model_id)=validate_info.ValidatedModelID{
|
||||
if let Some(model_id)=validate_info.ValidatedModelID{
|
||||
// upload to existing id
|
||||
let response=self.cookie_context.upload(rbx_asset::cookie::UploadRequest{
|
||||
assetid:model_id,
|
||||
@ -234,9 +232,10 @@ impl crate::message_handler::MessageHandler{
|
||||
groupId:None,
|
||||
},data).await.map_err(Error::AssetUpload)?;
|
||||
|
||||
response.AssetId
|
||||
// TODO: figure out model version
|
||||
(response.AssetId,1)
|
||||
}else{
|
||||
// grab the map instance from the map re
|
||||
// grab the map instance from the map ref
|
||||
let Some(map_instance)=dom.get_by_ref(map_ref)else{
|
||||
return Err(Error::ModelFileChildRefIsNil);
|
||||
};
|
||||
@ -249,27 +248,29 @@ impl crate::message_handler::MessageHandler{
|
||||
groupId:None,
|
||||
},data).await.map_err(Error::AssetCreate)?;
|
||||
|
||||
response.AssetId
|
||||
};
|
||||
|
||||
match validate_info.ResourceID{
|
||||
ResourceID::Mapfix(mapfix_id)=>{
|
||||
// update the mapfix to use the validated model
|
||||
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
||||
MapfixID:mapfix_id,
|
||||
ModelID:model_id,
|
||||
ModelVersion:1, //TODO
|
||||
}).await.map_err(Error::ApiUpdateMapfixModel)?;
|
||||
},
|
||||
ResourceID::Submission(submission_id)=>{
|
||||
// update the submission to use the validated model
|
||||
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
||||
SubmissionID:submission_id,
|
||||
ModelID:model_id,
|
||||
ModelVersion:1, //TODO
|
||||
}).await.map_err(Error::ApiUpdateSubmissionModel)?;
|
||||
},
|
||||
(response.AssetId,1)
|
||||
}
|
||||
}else{
|
||||
(validate_info.ModelID,validate_info.ModelVersion)
|
||||
};
|
||||
|
||||
match validate_info.ResourceID{
|
||||
ResourceID::Mapfix(mapfix_id)=>{
|
||||
// update the mapfix to use the validated model
|
||||
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
||||
MapfixID:mapfix_id,
|
||||
ModelID:validated_model_id,
|
||||
ModelVersion:validated_model_version,
|
||||
}).await.map_err(Error::ApiUpdateMapfixModel)?;
|
||||
},
|
||||
ResourceID::Submission(submission_id)=>{
|
||||
// update the submission to use the validated model
|
||||
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
||||
SubmissionID:submission_id,
|
||||
ModelID:validated_model_id,
|
||||
ModelVersion:validated_model_version,
|
||||
}).await.map_err(Error::ApiUpdateSubmissionModel)?;
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Loading…
x
Reference in New Issue
Block a user