AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
autoindex: name the flags when symlinks are skipped (#2823) (#2824)
xerj-org13c1edf629ae
diff --git a/engine/crates/xerj-autoindex/src/ignore_rules.rs b/engine/crates/xerj-autoindex/src/ignore_rules.rsindex 2b4fd5733..dd2ee27cc 100644--- a/engine/crates/xerj-autoindex/src/ignore_rules.rs+++ b/engine/crates/xerj-autoindex/src/ignore_rules.rs@@ -181,8 +181,9 @@ pub const HIDDEN_OUTSIDE_ROOT_RULE: &str = "symlink:outside-root+hidden";/// A symlink the walk did not follow. The default is not to follow links, and/// an unfollowed symlink is not a file to walkdir, so it used to be skipped/// with no line on the ignore report — a tree of links looked empty. One-/// warning names `--follow-symlinks`; each link is counted under this rule.-/// A target outside the folder stays refused even when the flag is on+/// warning names `--follow-symlinks` (and `--follow-symlinks-outside-root` for+/// targets outside the folder); each link is counted under this rule. A target+/// outside the folder stays refused with `--follow-symlinks` alone/// ([`ESCAPED_ROOT_RULE`]).pub const NOT_FOLLOWED_RULE: &str = "symlink:not-followed";@@ -847,7 +848,17 @@ impl IgnoreStack {/// A symlink target outside the indexed root, also decided by the walker/// (it needs the canonical root, which this stack does not carry) and/// reported through the same accounting. See [`ESCAPED_ROOT_RULE`].+ /// The warning is once per walk and names the flag that waives the+ /// boundary, so a tree of links to elsewhere does not look empty (#2823).pub fn record_symlink_escape(&mut self, path: &Path, is_dir: bool) {+ if !self.report.by_rule.contains_key(ESCAPED_ROOT_RULE) {+ self.warn(+ "symlink: target outside this folder, not followed (pass \+ --follow-symlinks-outside-root to index it; a link through a hidden folder \+ stays refused)"+ .into(),+ );+ }if is_dir {self.report.dirs_pruned += 1;self.report@@ -885,7 +896,8 @@ impl IgnoreStack {if !self.report.by_rule.contains_key(NOT_FOLLOWED_RULE) {self.warn("symlink: not followed (pass --follow-symlinks to index a target inside \- this folder; a target outside it stays refused)"+ this folder; add --follow-symlinks-outside-root as well for a target \+ outside it)".into(),);}diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rsindex 878f499f3..a82ccf681 100644--- a/engine/crates/xerj-autoindex/src/lib.rs+++ b/engine/crates/xerj-autoindex/src/lib.rs@@ -9458,6 +9458,9 @@ fn run_index_report_inner();} else {println!("no files found under {root_str}");+ if let Some(hint) = skipped_links_hint(&ignore_report) {+ println!("{hint}");+ }pr.finish(true, 0, "no-files", &[]);}return Ok((0, None));@@ -17730,3 +17733,74 @@ mod dataset_time_range_tests {}}}++/// The line printed when a walk found no files but skipped links, naming the+/// flags that would index them (#2823). `None` when no link was skipped.+pub(crate) fn skipped_links_hint(report: &ignore_rules::IgnoreReport) -> Option<String> {+ let count = |rule: &str| {+ report+ .by_rule+ .get(rule)+ .map_or(0, |c| c.files.saturating_add(c.dirs))+ };+ let not_followed = count(ignore_rules::NOT_FOLLOWED_RULE);+ let outside = count(ignore_rules::ESCAPED_ROOT_RULE);+ let total = not_followed.saturating_add(outside);+ if total == 0 {+ return None;+ }+ let flags = if outside > 0 {+ "--follow-symlinks --follow-symlinks-outside-root"+ } else {+ "--follow-symlinks (add --follow-symlinks-outside-root for targets outside the folder)"+ };+ Some(format!(+ "{total} symlink{} skipped: links are not followed by default. To index them, rerun with {flags}",+ if total == 1 { " was" } else { "s were" }+ ))+}++#[cfg(test)]+mod skipped_links_hint_tests {+ use super::skipped_links_hint;+ use crate::ignore_rules::{IgnoreReport, RuleCount, ESCAPED_ROOT_RULE, NOT_FOLLOWED_RULE};++ #[test]+ fn no_skipped_links_no_hint() {+ assert_eq!(skipped_links_hint(&IgnoreReport::default()), None);+ }++ #[test]+ fn unfollowed_links_name_the_flags() {+ let mut report = IgnoreReport::default();+ report.by_rule.insert(+ NOT_FOLLOWED_RULE.to_string(),+ RuleCount {+ files: 3,+ ..RuleCount::default()+ },+ );+ let hint = skipped_links_hint(&report).expect("links skipped: a hint");+ assert!(hint.starts_with("3 symlinks were skipped"), "{hint}");+ assert!(hint.contains("--follow-symlinks "), "{hint}");+ assert!(hint.contains("--follow-symlinks-outside-root"), "{hint}");+ }++ #[test]+ fn escaped_links_ask_for_both_flags() {+ let mut report = IgnoreReport::default();+ report.by_rule.insert(+ ESCAPED_ROOT_RULE.to_string(),+ RuleCount {+ dirs: 1,+ ..RuleCount::default()+ },+ );+ let hint = skipped_links_hint(&report).expect("escaped link: a hint");+ assert!(+ hint.contains("1 symlink was skipped")+ && hint.ends_with("--follow-symlinks --follow-symlinks-outside-root"),+ "{hint}"+ );+ }+}diff --git a/engine/crates/xerj-autoindex/src/walk.rs b/engine/crates/xerj-autoindex/src/walk.rsindex 6776a819e..e9beda484 100644--- a/engine/crates/xerj-autoindex/src/walk.rs+++ b/engine/crates/xerj-autoindex/src/walk.rs@@ -1495,7 +1495,12 @@ mod unfollowed_symlink_tests {"{report:?}");let lines = report.summary_lines().join("\n");- assert_eq!(lines.matches("--follow-symlinks").count(), 1, "{lines}");+ assert_eq!(lines.matches("--follow-symlinks ").count(), 1, "{lines}");+ assert_eq!(+ lines.matches("--follow-symlinks-outside-root").count(),+ 1,+ "the hint names the flag for an outside target (#2823): {lines}"+ );assert!(lines.contains(NOT_FOLLOWED_RULE), "{lines}");let (followed, followed_report) =@@ -1520,6 +1525,15 @@ mod unfollowed_symlink_tests {.any(|l| l.contains("symlink:outside-root")),"{followed_report:?}");+ let followed_lines = followed_report.summary_lines().join("\n");+ assert_eq!(+ followed_lines+ .matches("pass --follow-symlinks-outside-root")+ .count(),+ 1,+ "an escaped link names the flag that waives the boundary, once (#2823): \+ {followed_lines}"+ );}}