improve cache paths

This commit is contained in:
Ruben Fiszel
2023-08-29 15:29:55 +02:00
parent f3c96fe0cc
commit 75506e1ec9
2 changed files with 3 additions and 5 deletions
+2 -3
View File
@@ -986,7 +986,6 @@ async fn handle_queued_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>(
let cached_res_path = if job.cache_ttl.is_some() {
let args_hash = hash_args(&job.args.clone().unwrap_or_else(|| json!({})));
let permissioned_as = &job.permissioned_as;
if job.is_flow_step {
let flow_path = sqlx::query_scalar!(
"SELECT script_path FROM queue WHERE id = $1",
@@ -997,10 +996,10 @@ async fn handle_queued_job<R: rsmq_async::RsmqConnection + Send + Sync + Clone>(
.map_err(|e| Error::InternalErr(format!("fetching step flow status: {e}")))?
.ok_or_else(|| Error::InternalErr(format!("Expected script_path")))?;
let step = step.unwrap_or(-1);
Some(format!("{permissioned_as}/cache/{flow_path}/{step}/{args_hash}"))
Some(format!("{flow_path}/cache/{step}/{args_hash}"))
} else if let Some(script_path) = &job.script_path {
let is_flow = if job.is_flow() { "flow/" } else { "" };
Some(format!("{permissioned_as}/cache/{is_flow}{script_path}/{args_hash}"))
Some(format!("{script_path}/{is_flow}cache/{args_hash}"))
} else {
None
}
+1 -2
View File
@@ -584,9 +584,8 @@ pub async fn update_flow_status_after_job_completion_internal<
if flow_job.cache_ttl.is_some() {
let cached_res_path = {
let args_hash = hash_args(&flow_job.args.clone().unwrap_or_else(|| json!({})));
let permissioned_as = &flow_job.permissioned_as;
let flow_path = flow_job.script_path();
format!("{permissioned_as}/cache/flow/{flow_path}/{args_hash}")
format!("{flow_path}/flow/cache/{args_hash}")
};
save_in_cache(&client, &flow_job, cached_res_path, &nresult).await;