From febe4aa0d33f99c2bdf64ad00c496e7fc7f74cd0 Mon Sep 17 00:00:00 2001 From: slvnlrt Date: Thu, 12 Mar 2026 22:18:07 +0100 Subject: [PATCH] fix(locations): use exact match for root paths in system directory check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit path.starts_with(PathBuf::from("C:\\")) returns true for every path on drive C:, causing OneDrive and other user folders to be flagged as system directories during location validation. Extend the root path detection to cover Windows drive roots (C:\) in addition to the Unix root ("/") already handled. Use d.parent().is_none() which is true for both Unix "/" and Windows "C:\" — root paths must match exactly, not via starts_with. --- core/src/ops/locations/validate/query.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/ops/locations/validate/query.rs b/core/src/ops/locations/validate/query.rs index 34641f00f..bb7e398c5 100644 --- a/core/src/ops/locations/validate/query.rs +++ b/core/src/ops/locations/validate/query.rs @@ -83,9 +83,11 @@ impl LibraryQuery for ValidateLocationPathQuery { tracing::info!("Validating path: {} (depth: {})", path.display(), depth); tracing::info!("System directories: {:?}", system_dirs); let is_system_dir = system_dirs.iter().any(|d| { - // Special case: "/" should only match if path IS "/", not if it starts with "/" - // Otherwise every absolute path would be considered a system directory - let matches = if d.to_string_lossy() == "/" { + // Root paths (Unix "/" or Windows "C:\") must match exactly. + // Using starts_with() on a root dir would flag every child path as a + // system directory — e.g. "C:\" would match "C:\Users\alice\OneDrive". + let d_is_root = d.parent().is_none(); + let matches = if d_is_root { path == d } else { path.starts_with(d)