   If that path does not exists it will be automatically created,
   if it exists but is not a directory, an exception will be
   raised."
-  [{:keys [basedir baseuri] :as keys}]
+  [{:keys [basedir baseuri executor]
+    :or {executor (ForkJoinPool/commonPool)}
+    :as keys}]
   (let [^Path basepath (pt/-path basedir)
         ^URI baseuri (pt/-uri baseuri)]
     (when (and (fs/exists? basepath)

            [clojure.java.io :as io]
            [executors.core :as exec]
            [datoteka.proto :as pt]
            [datoteka.impl :as impl]
            [datoteka.core :as fs])
  (:import java.io.InputStream
           java.io.OutputStream

        ^Path fullpath (normalize-path base path)]
    (when-not (fs/exists? (.getParent fullpath))
      (fs/create-dir! (.getParent fullpath)))
    (with-open [^InputStream src (io/input-stream content)
                ^OutputStream dst (io/output-stream content)]
      (io/copy src dst)
      path)))

(defn- delete
  [base path]
  (let [path (->> (pt/-path path)
                  (normalize-path base))]
    (fs/delete-sigle path)))

(defn- submit
  [executor func]
  (let [supplier (reify Supplier (get [_] (func)))]
     (CompletableFuture/supplyAsync supplier executor)))

(defrecord LocalFileSystemBackend [^Path base
                                   ^URI baseuri
                                   ^ExecutorService executor]
  pt/IPublicStorage
  (-public-uri [_ path]
    (.resolve baseuri (str path)))

  pt/IStorage
  (-save [_ path content]
    (submit executor #(save base path content)))

  (-delete [_ path]
    (submit executor #(delete base path)))

  (-exists? [this path]
    (try
