       (put! res-ch (ex-info "Could not read key."
                             (assoc msg :exception t))))))
 
-(defn- list-keys
-  "Return all Keys of the Filestore."
-  [folder serializer read-handlers]
-  (let [path       (Paths/get folder (into-array String []))
-        file-paths (Files/newDirectoryStream path)]
-    (->> (reduce
-          (fn [list-keys path]
-            (if (and (Files/exists path (into-array LinkOption [])) (clojure.string/includes? (.toString path) ".ksv"))
-              (let [ac        (AsynchronousFileChannel/open path (into-array StandardOpenOption [StandardOpenOption/READ]))
-                    bb        (ByteBuffer/allocate Integer/BYTES)
-                    path-name (.toString path)
-                    env       {:operation :read-meta
-                               :msg       {:type :read-meta-error
-                                           :path path-name}}
-                    res-ch    (chan)]
-                (into list-keys [(go-try
-                                     (.read ac bb Integer/BYTES Long/BYTES
-                                            (completion-read-meta-size-handler res-ch bb
-                                                                               {:type :read-list-keys
-                                                                                :path path-name}))
-                                   (<? (read-file ac serializer read-handlers env (<? res-ch)))
-                                   (finally
-                                     (.clear bb)
-                                     (.close ac)
-                                     (close! res-ch)))]))
-              list-keys))
-          (list)
-          file-paths)
-         async/merge
-         (async/into #{}))))
-
 (defn completion-read-old-handler [res-ch bb serializer read-handlers msg]
   (proxy [CompletionHandler] []
     (completed [res att]

                                                            {:type :read-meta-size-error
                                                             :key  key}))
                (let [[ser meta-size] (<? res-ch)
                      old       (<? (read-file ac serializer read-handlers env meta-size))]
                  (if (or (= :write-edn operation) (= :write-binary operation))
                    (<? (update-file folder config path serializer write-handlers buffer-size key-vec env old))
                    old))

                                    (.close ac)
                                    (close! res-ch)))))
              (let [file-name (-> path .toString)
                    fn-l      (-> path .getFileName .toString)
                    env       (update-in env [:msg :keys] (fn [_] file-name))
                           ]
                (if (clojure.string/includes? file-name "meta")
                  (into list-keys (map
                                   #(let [old-file-name (-> % .toString)
                                          fn            (-> % .getFileName .toString)
                                          env           (assoc-in env [:msg :keys] old-file-name)]
                                      (migrate-file-v2 folder fn-l env buffer-size old-file-name file-name serializer read-handlers write-handlers))
                                   (Files/newDirectoryStream (Paths/get file-name (into-array String [])))))
                  (conj list-keys (migrate-file-v1 folder fn-l env buffer-size file-name file-name serializer read-handlers write-handlers))))))
          #{}
          file-paths)
         async/merge
         (async/into #{}))))

(defrecord FileSystemStore [folder serializer compressor encryptor read-handlers write-handlers buffer-size detect-old-version locks config]
  PEDNAsyncKeyValueStore
  (-get [this key]
    (io-operation [key] folder config serializer read-handlers write-handlers buffer-size {:operation :read-edn
                                                                                           :compressor compressor
                                                                                           :encryptor  encryptor
                                                                                           :format    :data
                                                                                           :version version
                                                                                           :detect-old-files detect-old-version
