From 304b90fa2751a024f294efe8bbe587d9524f3418 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 15 Jul 2024 20:14:37 +0200 Subject: [PATCH] fix: improve generate flow locks --- .../windmill-worker/src/worker_lockfiles.rs | 77 +++++++++++-------- cli/flow.ts | 5 +- cli/metadata.ts | 2 +- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/backend/windmill-worker/src/worker_lockfiles.rs b/backend/windmill-worker/src/worker_lockfiles.rs index 5f50648863..a489eb7e66 100644 --- a/backend/windmill-worker/src/worker_lockfiles.rs +++ b/backend/windmill-worker/src/worker_lockfiles.rs @@ -498,13 +498,31 @@ pub async fn handle_flow_dependency_job(v.get()).ok()) + .flatten() + }) + .flatten() + .unwrap_or(false); + + let version = if skip_flow_update { + None + } else { + Some( + job.script_hash + .clone() + .ok_or_else(|| { + Error::InternalErr( + "Flow Dependency requires script hash (flow version)".to_owned(), + ) + })? + .0, + ) + }; let raw_flow = job.raw_flow.clone().map(|v| Ok(v)).unwrap_or_else(|| { Err(Error::InternalErr( @@ -563,18 +581,12 @@ pub async fn handle_flow_dependency_job(v.get()).ok()) - .flatten() - }) - .flatten() - .unwrap_or(false); if !skip_flow_update { + let version = version.ok_or_else(|| { + Error::InternalErr("Flow Dependency requires script hash (flow version)".to_owned()) + })?; + sqlx::query!( "UPDATE flow SET value = $1 WHERE path = $2 AND workspace_id = $3", new_flow_value, @@ -590,22 +602,23 @@ pub async fn handle_flow_dependency_job x.substring(0, x.lastIndexOf(SEP))); let hasAny = false; - if (hasAny) { - log.info("Generating metadata for all stale flows:"); - } + for (const folder of elems) { const candidate = await generateFlowLockInternal(folder, true, workspace); if (candidate) { @@ -267,6 +265,7 @@ async function generateLocks( log.info(colors.green(`+ ${candidate}`)); } } + if (hasAny) { if ( !opts.yes && diff --git a/cli/metadata.ts b/cli/metadata.ts index ba5b85009e..e7f3bd6c7a 100644 --- a/cli/metadata.ts +++ b/cli/metadata.ts @@ -128,7 +128,7 @@ export async function generateFlowLockInternal( if (!justUpdateMetadataLock) { const changedScripts = []; - //find hashes that do not correspond to preivous hashes + //find hashes that do not correspond to previous hashes for (const [path, hash] of Object.entries(hashes)) { if (path == TOP_HASH) { continue;