inline very thin function
This commit is contained in:
parent
4116eaf829
commit
f9fb1fb23c
51
src/main.rs
51
src/main.rs
@ -311,21 +311,6 @@ async fn check_or_create_script_poicy(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_policy(
|
|
||||||
api:&submissions_api::external::Context,
|
|
||||||
script_ids:&std::collections::HashMap<&str,submissions_api::types::ScriptID>,
|
|
||||||
source:&str,
|
|
||||||
to_script_id:submissions_api::types::ScriptID,
|
|
||||||
policy:submissions_api::types::Policy,
|
|
||||||
)->Result<(),GOCError>{
|
|
||||||
let hash=hash_format(hash_source(source));
|
|
||||||
check_or_create_script_poicy(api,hash.as_str(),submissions_api::types::CreateScriptPolicyRequest{
|
|
||||||
FromScriptID:script_ids[source],
|
|
||||||
ToScriptID:to_script_id,
|
|
||||||
Policy:policy,
|
|
||||||
}).await
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UploadConfig{
|
struct UploadConfig{
|
||||||
session_id:String,
|
session_id:String,
|
||||||
api_url:String,
|
api_url:String,
|
||||||
@ -377,36 +362,42 @@ async fn upload_scripts(config:UploadConfig)->Result<(),ScriptUploadError>{
|
|||||||
// replace
|
// replace
|
||||||
let replace_fut=futures::stream::iter(replace_map.iter().map(Ok))
|
let replace_fut=futures::stream::iter(replace_map.iter().map(Ok))
|
||||||
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|(source,id)|async{
|
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|(source,id)|async{
|
||||||
do_policy(
|
check_or_create_script_poicy(
|
||||||
api,
|
api,
|
||||||
&script_ids,
|
hash_format(hash_source(source)).as_str(),
|
||||||
source,
|
submissions_api::types::CreateScriptPolicyRequest{
|
||||||
script_ids[allowed_map[id].as_str()],
|
FromScriptID:script_ids[source.as_str()],
|
||||||
submissions_api::types::Policy::Replace
|
ToScriptID:script_ids[allowed_map[id].as_str()],
|
||||||
|
Policy:submissions_api::types::Policy::Replace,
|
||||||
|
}
|
||||||
).await.map_err(ScriptUploadError::GOCPolicyReplace)
|
).await.map_err(ScriptUploadError::GOCPolicyReplace)
|
||||||
});
|
});
|
||||||
|
|
||||||
// allowed
|
// allowed
|
||||||
let allowed_fut=futures::stream::iter(allowed_set.iter().map(Ok))
|
let allowed_fut=futures::stream::iter(allowed_set.iter().map(Ok))
|
||||||
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|source|async{
|
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|source|async{
|
||||||
do_policy(
|
check_or_create_script_poicy(
|
||||||
api,
|
api,
|
||||||
&script_ids,
|
hash_format(hash_source(source)).as_str(),
|
||||||
source,
|
submissions_api::types::CreateScriptPolicyRequest{
|
||||||
script_ids[source.as_str()],
|
FromScriptID:script_ids[source.as_str()],
|
||||||
submissions_api::types::Policy::Allowed
|
ToScriptID:script_ids[source.as_str()],
|
||||||
|
Policy:submissions_api::types::Policy::Allowed,
|
||||||
|
}
|
||||||
).await.map_err(ScriptUploadError::GOCPolicyAllowed)
|
).await.map_err(ScriptUploadError::GOCPolicyAllowed)
|
||||||
});
|
});
|
||||||
|
|
||||||
// blocked
|
// blocked
|
||||||
let blocked_fut=futures::stream::iter(blocked_set.iter().map(Ok))
|
let blocked_fut=futures::stream::iter(blocked_set.iter().map(Ok))
|
||||||
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|source|async{
|
.try_for_each_concurrent(Some(REMOTE_CONCURRENCY),|source|async{
|
||||||
do_policy(
|
check_or_create_script_poicy(
|
||||||
api,
|
api,
|
||||||
&script_ids,
|
hash_format(hash_source(source)).as_str(),
|
||||||
source,
|
submissions_api::types::CreateScriptPolicyRequest{
|
||||||
script_ids[source.as_str()],
|
FromScriptID:script_ids[source.as_str()],
|
||||||
submissions_api::types::Policy::Blocked
|
ToScriptID:script_ids[source.as_str()],
|
||||||
|
Policy:submissions_api::types::Policy::Blocked,
|
||||||
|
}
|
||||||
).await.map_err(ScriptUploadError::GOCPolicyBlocked)
|
).await.map_err(ScriptUploadError::GOCPolicyBlocked)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user