             [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 source (pt/-input-stream content)
                ^OutputStream dest (Files/newOutputStream
                                    fullpath fs/write-open-opts)]
      (io/copy source dest)
      path)))

(defn- delete
  [base path]
  (let [path (->> (pt/-path path)
                  (normalize-path base))]
    (Files/deleteIfExists ^Path path)))

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

  pt/IStorage
  (-save [_ path content]
    (exec/submit (partial save base path content)))

  (-delete [_ path]
    (exec/submit (partial delete base path)))

  (-exists? [this path]
    (try


  pt/IClearableStorage
  (-clear [_]
    (fs/delete base)
    (fs/create-dir base))

  pt/ILocalStorage
  (-lookup [_ path']
