     [clojure.string :as string]
     [vault.blob.core :as blob :refer [BlobStore]])
   (:import
-    (java.io
-      File)))
+    java.io.File
+    java.util.Date))
 
 
 ;; HELPER FUNCTIONS
 
-(defn- hashid->file
+(defn- id->file
   ^File
   [root id]
   (let [id (blob/hash-id id)
         {:keys [algorithm digest]} id]
     (io/file root
-             (name algorithm)
-             (subs digest 0 3)
-             (subs digest 3 6)
-             (subs digest 6))))
+      (name algorithm)
+      (subs digest 0 3)
+      (subs digest 3 6)
+      (subs digest 6))))
 
 
-(defn- file->hashid
+(defn- file->id
   [root file]
   (let [root (str root)
         file (str file)]



(defn- enumerate-files
  "Generates a lazy sequence of file blobs contained in a root directory."
  [^File root]
  ; TODO: intelligently skip entries based on 'after'
  (flatten

        (for-files [midfix-dir prefix-dir]
          (for-files [blob midfix-dir]
            blob))))))


(defmacro ^:private when-blob-file
  "This is an unhygenic macro which binds the blob file to 'file' and executes
  the body only if it exists."
  [store id & body]
  `(let [~(with-meta 'file {:tag 'java.io.File})
         (id->file (:root ~store) ~id)]
     (when (.exists ~'file)
       ~@body)))



