mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-11 00:06:06 +00:00
fix: fix rebuild_dependency_map (#7026)
* nit: fix rebuild_dependency_map Signed-off-by: pyranota <pyra@duck.com> * ignore archived flows Signed-off-by: pyranota <pyra@duck.com> --------- Signed-off-by: pyranota <pyra@duck.com>
This commit is contained in:
@@ -10,7 +10,10 @@ use windmill_common::{
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::worker_lockfiles::{extract_relative_imports, LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT};
|
||||
use crate::worker_lockfiles::{
|
||||
extract_relative_imports, is_generated_from_raw_requirements,
|
||||
LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT,
|
||||
};
|
||||
|
||||
// TODO: To be removed in future versions
|
||||
lazy_static::lazy_static! {
|
||||
@@ -282,7 +285,7 @@ SELECT importer_node_id, imported_path
|
||||
// Scripts
|
||||
tracing::info!(workspace_id = w_id, "Rebuilding dependency map for scripts");
|
||||
for r in sqlx::query!(
|
||||
"SELECT path, hash FROM script WHERE workspace_id = $1 AND archived = false",
|
||||
"SELECT path, hash FROM script WHERE workspace_id = $1 AND archived = false AND deleted = false",
|
||||
w_id
|
||||
)
|
||||
.fetch_all(db)
|
||||
@@ -323,7 +326,7 @@ SELECT importer_node_id, imported_path
|
||||
// Fetch only top level versions and paths
|
||||
// It is not fetching value
|
||||
tracing::info!(workspace_id = w_id, "Rebuilding dependency map for flows");
|
||||
for r in sqlx::query!("SELECT path, versions[array_upper(versions, 1)] as version FROM flow WHERE workspace_id = $1", w_id).fetch_all(db).await? {
|
||||
for r in sqlx::query!("SELECT path, versions[array_upper(versions, 1)] as version FROM flow WHERE workspace_id = $1 AND archived = false", w_id).fetch_all(db).await? {
|
||||
if let Some(version) = r.version {
|
||||
// To reduce stress on db try to fetch from cache
|
||||
// Since our flow versions are immutable it is safe to assume if we have cache for specific version/id it is up to date.
|
||||
@@ -346,15 +349,17 @@ SELECT importer_node_id, imported_path
|
||||
FlowValue::traverse_leafs(modules_to_check, &mut |fmv, id| {
|
||||
match fmv {
|
||||
// Since we fetched from flow_version it is safe to assume all inline scripts are in form of RawScript.
|
||||
FlowModuleValue::RawScript { content, language, .. } => {
|
||||
to_process.push((
|
||||
extract_relative_imports(
|
||||
content,
|
||||
&(r.path.clone() + "/flow"),
|
||||
&Some(language.clone()),
|
||||
),
|
||||
id.clone(),
|
||||
));
|
||||
FlowModuleValue::RawScript { content, language, lock ,.. } => {
|
||||
if !is_generated_from_raw_requirements(Some(*language), lock) {
|
||||
to_process.push((
|
||||
extract_relative_imports(
|
||||
content,
|
||||
&(r.path.clone() + "/flow"),
|
||||
&Some(language.clone()),
|
||||
),
|
||||
id.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
// But just in case we will also handle other cases.
|
||||
FlowModuleValue::FlowScript { .. } => {
|
||||
|
||||
@@ -445,7 +445,7 @@ pub async fn process_relative_imports(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_generated_from_raw_requirements(lang: Option<ScriptLang>, lock: &Option<String>) -> bool {
|
||||
pub fn is_generated_from_raw_requirements(lang: Option<ScriptLang>, lock: &Option<String>) -> bool {
|
||||
(lang.is_some_and(|v| v == ScriptLang::Bun)
|
||||
&& lock
|
||||
.as_ref()
|
||||
|
||||
Reference in New Issue
Block a user