X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Monitor.vala;h=c268db10bdf0ddb7179e0b8f796441d9cc3e8e74;hb=refs%2Fheads%2Fmaster;hp=d86d99d71fe4379529c4005368b28b4666fa1551;hpb=69e9a65fbddc9630102c4bfdc8974777ae46150b;p=gitlive diff --git a/Monitor.vala b/Monitor.vala index d86d99d7..c268db10 100644 --- a/Monitor.vala +++ b/Monitor.vala @@ -68,11 +68,16 @@ public delegate void onEventHander (FileMonitor fm, File f_orig, File of_orig, F * */ -public class Monitor : Object +public abstract class gitMonitorBase : Object +{ + public abstract void monitor(string path, int depth = 0); +} + +public class Monitor : gitMonitorBase { - + static int total_monitors = 0; public Monitor() { @@ -136,7 +141,7 @@ public class Monitor : Object * * */ - public void monitor(string path, int depth = 0) + public override void monitor(string path, int depth = 0) { //GLib.debug("ADD: (%d): %s\n", depth, path); @@ -159,9 +164,15 @@ public class Monitor : Object fm.changed.connect( this.onEvent ); this.monitors.append_val(fm); + + + total_monitors++; + GLib.debug("Total Monitors this: %d, All:%d: %s", (int)this.monitors.length, total_monitors, path); + } catch (Error e) { - GLib.debug("Error adding monitor: %s", e.message); + GLib.debug("Error adding monitor: %s\n", e.message); + GLib.debug("Try: \n\nsudo su\necho 512 > /proc/sys/fs/inotify/max_user_instances\n"); // FIXME -- show error? do nothing.. } // print("ADD path " + depth + ' ' + path); @@ -275,25 +286,9 @@ public class Monitor : Object MonitorNamePathDir src = new MonitorNamePathDir( f.get_basename(), f.get_path() , Path.get_dirname(f.get_path())); - - - - //string event_name = "UKNOWN"; - - - // extract the event names ... - not sure if introspection is feasible in vala.. - //for(var i in Gio.FileMonitorEvent) { - // if (Gio.FileMonitorEvent[i] == event_type) { - // event_name = i; - // } - //} - - - - - //print (JSON.stringify([event_name , f.get_path(), of ? of.get_path() : false ] )); - //print ("got src: " + src.toString()); - //print ("got event: " + src.toString()); + + GLib.debug("onEvent src: %s", f.get_path()); + try { @@ -327,14 +322,23 @@ public class Monitor : Object case FileMonitorEvent.MOVED_IN: // eg. chmod/chatt case FileMonitorEvent.MOVED_OUT: // eg. chmod/chatt case FileMonitorEvent.RENAMED: // eg. chmod/chatt - - var of = this.realpath(of_orig); + if (of_orig == null) { // move from outside of monitoring? + this.onChanged(src); + return; + } + + + var of = this.realpath(of_orig); var dest = new MonitorNamePathDir( of.get_basename(), of.get_path(), Path.get_dirname(of.get_path()) ); - + + if (dest == null) { + + return; + } src.action = "moved"; dest.action = "moved"; this.onMoved(src,dest);