 (defn- import-icon
   [conn id fpath]
   {:pre [(uuid? id) (fs/path? fpath)]}
-  (println "Importing icon:" (str fpath))
   (let [filename (fs/base-name fpath)
-        iconid (uuid/namespaced +imates-uuid-ns+ (str id filename))]
-    (create-icon conn id iconid fpath)))
+        iconid (uuid/namespaced +icons-uuid-ns+ (str id filename))]
+    (when-not (retrieve-icon conn iconid)
+      (println "Importing icon:" (str fpath))
+      (create-icon conn id iconid fpath))))
 
 (defn- process-icons-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- import-image
  [conn id fpath]
  {:pre [(uuid? id) (fs/path? fpath)]}
  (let [filename (fs/base-name fpath)
        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))

(defn- process-images-entry
  [conn basedir {:keys [path regex] :as entry}]
