|
| 1 | +From fcc1689f60a11ce13252daa2196ce8d6dec05783 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Maxi Wittich <maximilian.wittich@stackable.tech> |
| 3 | +Date: Fri, 6 Mar 2026 15:03:02 +0100 |
| 4 | +Subject: Adding patch to allow symlinks in git-sync pathes without error und |
| 5 | + siblings |
| 6 | + |
| 7 | +--- |
| 8 | + airflow-core/src/airflow/utils/file.py | 28 +++++++++++++++++--------- |
| 9 | + 1 file changed, 18 insertions(+), 10 deletions(-) |
| 10 | + |
| 11 | +diff --git a/airflow-core/src/airflow/utils/file.py b/airflow-core/src/airflow/utils/file.py |
| 12 | +index 12138043b8..9ef680fc28 100644 |
| 13 | +--- a/airflow-core/src/airflow/utils/file.py |
| 14 | ++++ b/airflow-core/src/airflow/utils/file.py |
| 15 | +@@ -199,17 +199,25 @@ def _find_path_from_directory( |
| 16 | + # so that later patterns can override earlier patterns |
| 17 | + patterns = list(dict.fromkeys(patterns)) |
| 18 | + |
| 19 | +- dirs[:] = [subdir for subdir in dirs if not ignore_rule_type.match(Path(root) / subdir, patterns)] |
| 20 | +- |
| 21 | +- # explicit loop for infinite recursion detection since we are following symlinks in this walk |
| 22 | +- for sd in dirs: |
| 23 | +- dirpath = (Path(root) / sd).resolve() |
| 24 | ++ dirs_sorted = sorted(dirs, key=lambda d: not (Path(root) / d).is_symlink()) |
| 25 | ++ accepted_dirs: list[str] = [] |
| 26 | ++ for subdir in dirs_sorted: |
| 27 | ++ if ignore_rule_type.match(Path(root) / subdir, patterns): |
| 28 | ++ continue |
| 29 | ++ dirpath = (Path(root) / subdir).resolve() |
| 30 | + if dirpath in patterns_by_dir: |
| 31 | +- raise RuntimeError( |
| 32 | +- "Detected recursive loop when walking DAG directory " |
| 33 | +- f"{base_dir_path}: {dirpath} has appeared more than once." |
| 34 | +- ) |
| 35 | +- patterns_by_dir.update({dirpath: patterns.copy()}) |
| 36 | ++ log.debug( |
| 37 | ++ "Skipping %s: already visited via resolved path %s. " |
| 38 | ++ "This is expected when a symlink and its target are siblings " |
| 39 | ++ "(e.g. a git-sync versioned directory alongside its 'link' symlink). ", |
| 40 | ++ Path(root) / subdir, |
| 41 | ++ dirpath, |
| 42 | ++ ) |
| 43 | ++ continue |
| 44 | ++ patterns_by_dir[dirpath] = patterns.copy() |
| 45 | ++ accepted_dirs.append(subdir) |
| 46 | ++ # Only adding unique subdirs |
| 47 | ++ dirs[:] = accepted_dirs |
| 48 | + |
| 49 | + for file in files: |
| 50 | + if file != ignore_file_name: |
0 commit comments