mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 23:18:06 -04:00
fix(locations): use exact match for root paths in system directory check
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user