Support native macOS speech relocation and safe indexing

This commit is contained in:
karl committed 2026-10-23 09:43:42 +02:00
1 parent 9a93ee6375
commit 5b93dd67a7
8 files changed
+287 -14

No files matched your search

@@ -59,6 +59,14 @@ pub fn exclusions() -> Vec<PathBuf> {
.iter()
.map(PathBuf::from)
.collect();
#[cfg(target_os = "macos")]
{
paths.extend(["/System", "/Volumes", "/private"].map(PathBuf::from));
// App state, VM disks and OS caches are not personal searchable documents.
if let Some(home) = std::env::var_os("HOME") {
paths.push(PathBuf::from(home).join("Library"));
}
}
#[cfg(windows)]
if let Some(local) = std::env::var_os("LOCALAPPDATA") {
paths.push(PathBuf::from(local).join("Programs"));
@@ -156,6 +164,27 @@ mod tests {
assert!(exclusions().iter().all(|path| path.is_absolute()));
}
#[cfg(target_os = "macos")]
#[test]
fn mac_scan_prunes_system_mounts_and_app_state_but_keeps_documents() {
let excluded = exclusions();
let home = PathBuf::from(std::env::var_os("HOME").expect("Mac user home"));
for path in [
PathBuf::from("/System"),
PathBuf::from("/Volumes"),
home.join("Library"),
] {
let canonical = super::super::data_directory::canonical_exclusion(&path).unwrap();
assert!(
excluded.contains(&canonical),
"unpruned Mac path: {}",
path.display()
);
}
let documents = home.join("Documents");
assert!(!excluded.iter().any(|p| documents.starts_with(p)));
}
#[test]
fn automatic_scan_keeps_documents_and_prunes_credential_stores() {
let dir = tempfile::tempdir().unwrap();
+7 -5
View File
@@ -522,11 +522,13 @@ mod tests {
.expect("watch reconciliation")
}
#[test]
fn native_windows_or_linux_create_update_rename_delete() {
let root = tempfile::tempdir().unwrap();
fn native_create_update_rename_delete() {
let directory = tempfile::tempdir().unwrap();
// Match canonical production roots; macOS FSEvents emits /private/var paths.
let root = std::fs::canonicalize(directory.path()).unwrap();
let (tx, rx) = mpsc::channel();
let service = WatchService::start_timed(
vec![root.path().to_owned()],
vec![root.clone()],
vec![],
move |r| {
tx.send(r).unwrap();
@@ -536,8 +538,8 @@ mod tests {
)
.unwrap();
assert!(receive(&rx).paths.is_none());
let first = root.path().join("first.txt");
let second = root.path().join("second.txt");
let first = root.join("first.txt");
let second = root.join("second.txt");
std::fs::write(&first, "one").unwrap();
assert!(receive(&rx).paths.unwrap().contains(&first));
std::fs::write(&first, "two").unwrap();