From 8bd48c629079d270655ce9782fd38e5a53d93cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sun, 16 Jan 2022 20:06:44 +1300 Subject: [PATCH] Don't fail if we can't canonicalize an event path e.g. for deletes --- lib/src/fs.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/fs.rs b/lib/src/fs.rs index 0b4546c..83969fd 100644 --- a/lib/src/fs.rs +++ b/lib/src/fs.rs @@ -11,7 +11,7 @@ use std::{ use notify::Watcher as _; use tokio::sync::{mpsc, watch}; -use tracing::{debug, error, trace}; +use tracing::{debug, error, trace, warn}; use crate::{ error::{CriticalError, RuntimeError}, @@ -286,10 +286,10 @@ fn process_event( // possibly pull file_type from whatever notify (or the native driver) returns? tags.push(Tag::Path { file_type: metadata(&path).ok().map(|m| m.file_type().into()), - path: dunce::canonicalize(path).map_err(|err| RuntimeError::IoError { - about: "canonicalise path in event", - err, - })?, + path: dunce::canonicalize(&path).unwrap_or_else(|err| { + warn!(?err, ?path, "failed to canonicalise event path"); + path + }), }); }