Don't fail if we can't canonicalize an event path

e.g. for deletes
This commit is contained in:
Félix Saparelli 2022-01-16 20:06:44 +13:00
parent 4737937350
commit 8bd48c6290
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 5 additions and 5 deletions

View File

@ -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
}),
});
}