Add path normalization helper and apply

This commit is contained in:
thePR0M3TH3AN
2025-05-24 21:59:31 -04:00
parent 06d96fd3f1
commit 313e54586a
6 changed files with 41 additions and 12 deletions

View File

@@ -6,6 +6,7 @@
//! watcher can be paused, resumed and shut down cleanly.
use crate::db::{self, Database};
use crate::utils::to_db_path;
use anyhow::{anyhow, Context, Result};
use crossbeam_channel::{bounded, Receiver};
use notify::{
@@ -463,8 +464,8 @@ impl FileWatcher {
// update DB for renames
if let EventKind::Modify(ModifyKind::Name(_)) = ev.kind {
if let (Some(old_p), Some(new_p)) = (&ev.old_path, &ev.new_path) {
let old_s = old_p.to_string_lossy();
let new_s = new_p.to_string_lossy();
let old_s = to_db_path(old_p);
let new_s = to_db_path(new_p);
let res =
handle_db_update(db_mutex, &old_s, &new_s, new_p.is_dir());
if let Err(e) = res {