MergeBranch.bjs
[gitlive] / Monitor.vala
index 1b5c499..b8e3bce 100644 (file)
@@ -166,7 +166,8 @@ public class Monitor : gitMonitorBase
                 this.monitors.append_val(fm);
 
             } 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);
@@ -280,25 +281,9 @@ public class Monitor : gitMonitorBase
         
  
         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 {
                 
 
@@ -332,14 +317,23 @@ public class Monitor : gitMonitorBase
                 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);