Skip to content

Commit

Permalink
Correcting IO::Notification.watch-path event paths for individual files
Browse files Browse the repository at this point in the history
Handle watching individual files for file system events. The
IO::Notification::Change.path should correctly point to the file path of the file.
  • Loading branch information
ashgti committed Sep 7, 2017
1 parent e7a5880 commit 2362dfd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/IO/Notification.pm
Expand Up @@ -16,6 +16,7 @@ my class IO::Notification {
}

method watch-path(Str() $path, :$scheduler = $*SCHEDULER) {
my $is-dir = $path.IO.d;
my $s = Supplier.new;
nqp::watchfile(
$scheduler.queue,
Expand All @@ -25,7 +26,8 @@ my class IO::Notification {
}
else {
my $event = rename ?? FileRenamed !! FileChanged;
$s.emit(Change.new(:path($*SPEC.catdir($path, path)), :$event));
my $full-path = $is-dir ?? $*SPEC.catdir($path, path) !! $path;
$s.emit(Change.new(:path($full-path), :$event));
}
},
$path, FileWatchCancellation);
Expand Down

0 comments on commit 2362dfd

Please sign in to comment.