   [cgdata/detect-cgdata
    cgdata/detect-tsv])
 
-(defn file-changed [loader kind file]
-  (cond
-    (= :created kind) (loader file)
-    (= :modified kind) (loader file))) ; XXX ignoring deletes, for the moment.
+; Full reload metadata. The loader will skip
+; data files with unchanged hashes.
+(defn file-changed [loader docroot kind file]
+  (doseq [f (rest (file-seq (io/file docroot)))] ; skip docroot (the first element)
+    (try (loader f)
+      (catch Exception e (println (str "caught exception: " (.getMessage e))))))) ; XXX this is unhelpful. Log it somewhere.
 
 (def xenadir-default (str (io/file (System/getProperty  "user.home") "xena")))
 (def docroot-default (str (io/file xenadir-default "files")))

(comment (defn- print-datasets []
   (dorun (map println (datasets)))))

; XXX should add ring jsonp
(defn- get-app [db loader]
  (-> cavm.views.datasets/routes
      (wrap-trace :header :ui)

(ns cavm.core
  (:require [clojure.string :as s])
  (:require [cavm.h2 :refer [create-xenadb]])
  (:require [clojure.java.io :as io])
  (:require [ring.adapter.jetty :refer [run-jetty]])
  (:require [clojure.data.json :as json])
  (:require [me.raynes.fs :as fs])
