Update to make Dir::monitor watch inodes instead of file names.

This commit is contained in:
Seth Hall 2013-04-22 21:53:00 -04:00
parent 035b668f73
commit 08348b2bc2

View file

@ -23,11 +23,11 @@ export {
event Dir::monitor_ev(dir: string, last_files: set[string], callback: function(fname: string)) event Dir::monitor_ev(dir: string, last_files: set[string], callback: function(fname: string))
{ {
when ( local result = Exec::run([$cmd=fmt("ls \"%s\"", str_shell_escape(dir))]) ) when ( local result = Exec::run([$cmd=fmt("ls -i \"%s/\"", str_shell_escape(dir))]) )
{ {
if ( result$exit_code != 0 ) if ( result$exit_code != 0 )
{ {
Reporter::warning("Requested monitoring of non-existent directory."); Reporter::warning(fmt("Requested monitoring of non-existent directory (%s).", dir));
return; return;
} }
@ -35,9 +35,10 @@ event Dir::monitor_ev(dir: string, last_files: set[string], callback: function(f
local files = result$stdout; local files = result$stdout;
for ( i in files ) for ( i in files )
{ {
if ( files[i] !in last_files ) local parts = split1(files[i], / /);
callback(build_path_compressed(dir, files[i])); if ( parts[1] !in last_files )
add current_files[files[i]]; callback(build_path_compressed(dir, parts[2]));
add current_files[parts[1]];
} }
schedule polling_interval { Dir::monitor_ev(dir, current_files, callback) }; schedule polling_interval { Dir::monitor_ev(dir, current_files, callback) };
} }