 (defn- import-image
   [conn id fpath]
   {:pre [(uuid? id) (fs/path? fpath)]}
-  (println "Importing image:" (str fpath))
   (let [filename (fs/base-name fpath)
-        imageid (uuid/namespaced +imates-uuid-ns+ (str id filename))]
-    (if-let [image (retrieve-image conn imageid)]
+        imageid (uuid/namespaced +images-uuid-ns+ (str id filename))]
+    (when-not (retrieve-image conn imageid)
+      (println "Importing image:" (str fpath))
+      (create-image conn id imageid fpath))))
+
+    #_(if-let [image (retrieve-image conn imageid)]
       (do
         (delete-image conn image)
         (create-image conn id imageid fpath))
-      (create-image conn id imageid fpath))))
+      (create-image conn id imageid fpath))
 
 (defn- process-images-entry
   [conn basedir {:keys [path regex] :as entry}]

(defn- create-icons-collection
  "Create or replace image collection by its name."
  [conn {:keys [name] :as entry}]
  (println "Creating icons collection:" name)
  (let [id (uuid/namespaced +icons-uuid-ns+ name)
        sqlv (sql/create-icons-collection {:id id :name name})]
    (sc/execute conn sqlv)

(defn- create-images-collection
  "Create or replace image collection by its name."
  [conn {:keys [name] :as entry}]
  (println "Creating or updating image collection:" name)
  (let [id (uuid/namespaced +images-uuid-ns+ name)
        sqlv (sql/create-images-collection {:id id :name name})]
    (sc/execute conn sqlv)
    id))
