           (.clear buffer)
           (.close bos)))))
 
+;TODO merge 2-8 byte
 (defn- update-file
   "Write File into Filesystem. It Write first the meta-size, that is stored in (1Byte), the meta-data and the actual data."
-  [folder config path serializer write-handlers buffer-size [key & rkey] {:keys [file-name up-fn up-fn-args up-fn-meta type config operation input msg]} [old-meta old-value]]
+  [folder config path serializer write-handlers buffer-size [key & rkey] {:keys [version file-name up-fn up-fn-args up-fn-meta type config operation input msg]} [old-meta old-value]]
   (try
     (let [path-new             (Paths/get (str file-name ".new") (into-array String []))
           standard-open-option (into-array StandardOpenOption
                                            [StandardOpenOption/WRITE
                                             StandardOpenOption/CREATE])
           ac-new               (AsynchronousFileChannel/open path-new standard-open-option)
-          meta                 (apply up-fn-meta old-meta up-fn-args)
+          meta                 (up-fn-meta old-meta)
           value                (when (= operation :write-edn)
                                  (if-not (empty? rkey)
                                    (apply update-in old-value rkey up-fn up-fn-args)

      (<? res-ch)
      (finally
        (.clear bb)))))

(defn completion-read-meta-size-handler
  "Callback Function for io/operation. Return the Meta-size that are stored in the ByteBuffer."
  [res-ch ^ByteBuffer bb msg]
  (proxy [CompletionHandler] []
    (completed [res att]
      (let [bais      (ByteArrayInputStream. (.array bb))
            meta-size (.read bais)
            _         (.close bais)]
        (try

                                                 :folder path})))
    (.delete test-file)))


(defn detect-old-file-schema [folder]
  (reduce
   (fn [black-list path]
     (let [file-name (-> path .toString)]
       (if (clojure.string/includes? (-> path .getFileName .toString) "meta")
         (into black-list (detect-old-file-schema file-name))
         (if (clojure.string/includes? file-name ".ksv")
           black-list
           (into black-list [file-name])))))
   #{}
   (Files/newDirectoryStream (Paths/get folder (into-array String [])))))

(defn new-fs-store
  "Create Filestore in given path.
  Optional serializer, read-handerls, write-handlers, buffer-size and config (for fsync) can be changed.
