Working on automatic rmdom for bad domains during regen
[hcoop/domtool2.git] / src / slave.sml
index 3262b52..01d872c 100644 (file)
@@ -22,9 +22,12 @@ structure Slave :> SLAVE = struct
 
 datatype file_action =
         Add
-       | Delete
+       | Delete of bool
        | Modify
 
+fun isDelete (Delete _) = true
+  | isDelete _ = false
+
 type file_status = {action : file_action,
                    domain : string,
                    dir : string,
@@ -58,10 +61,13 @@ fun registerPostHandler handler =
 fun handleChanges fs = (!preHandler ();
                        app (fn recd as {action, file, ...} =>
                                (!fileHandler recd;
-                                if action = Delete andalso Posix.FileSys.access (file, []) then
-                                    OS.FileSys.remove file
-                                else
-                                    ())) fs;
+                                case action of
+                                    Delete b =>
+                                    if b andalso Posix.FileSys.access (file, []) then
+                                        OS.FileSys.remove file
+                                    else
+                                        ()
+                                  | _ => ())) fs;
                        !postHandler ())
 
 fun shell ss = OS.Process.isSuccess (OS.Process.system (String.concat ss))