   (:import [java.io
             DataInputStream DataOutputStream
             FileInputStream FileOutputStream]
-           [java.nio.file Files StandardCopyOption]))
+           [java.nio.channels FileChannel]
+           [java.nio.file Files StandardCopyOption FileSystems Path OpenOption]))
 
 ;; A useful overview over fsync on Linux:
 ;; https://www.usenix.org/conference/osdi14/technical-sessions/presentation/pillai
+
+
+(defn- sync-folder [folder]
+  (let [p (.getPath (FileSystems/getDefault) folder (into-array String []))]
+    (.force (FileChannel/open p (into-array OpenOption [])) true)))
 
 
 (defn delete-store

            (.flush dos)
            (when (:fsync config)
              (.sync fd))
            #_(.renameTo new-file f)
            (Files/move (.toPath new-file) (.toPath f)
                        (into-array [StandardCopyOption/ATOMIC_MOVE]))
            (when (:fsync config)
              (.sync fd)
              #_(.sync (.getFD (FileInputStream. (io/file folder)))))
            (catch Exception e
              (.delete new-file)
              (.sync fd)
              (ex-info "Could not write key."
                       {:type :write-error
                        :key key
                        :exception e}))
            (finally
              (.close fos))))))))



(defn new-fs-store

  (let [f (io/file folder)]
    (doseq [c (.list f)]
      (.delete (io/file (str folder "/" c))))
    (.delete f)
    (try
      (sync-folder folder)
      (catch Exception e
        nil))))


(defn list-keys
