Skip to content

Commit

Permalink
trigger update on all rename events
Browse files Browse the repository at this point in the history
partly because of notify-rs/notify#371 but also
because if the file gets renamed then it's just as if it was deleted and
we already handling the remove
  • Loading branch information
ecioppettini committed May 3, 2022
1 parent e619833 commit 4f52abc
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions vit-servicing-station-lib/src/server/snapshot_watcher.rs
Expand Up @@ -79,6 +79,8 @@ pub async fn async_watch(path: PathBuf, context: SharedContext) -> Result<Watche
}
};

trace!(?event);

if !event
.paths
.iter()
Expand All @@ -88,23 +90,13 @@ pub async fn async_watch(path: PathBuf, context: SharedContext) -> Result<Watche
return;
}

trace!(?event);

match event.kind {
EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime))
| EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any))
| EventKind::Create(CreateKind::File)
| EventKind::Remove(RemoveKind::File)
| EventKind::Access(AccessKind::Close(AccessMode::Write))
| EventKind::Modify(ModifyKind::Name(RenameMode::To))
| EventKind::Modify(ModifyKind::Name(RenameMode::Both))
if event
.paths
.get(1)
.and_then(|p| p.file_name())
.map(|fname| fname == file_name)
.unwrap_or(false) =>
{
| EventKind::Modify(ModifyKind::Name(_)) => {
if tx.send(()).is_err() {
warn!(
"failed to propagate snapshot file update event, this shouldn't happen"
Expand Down

0 comments on commit 4f52abc

Please sign in to comment.