diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2012-06-25 22:31:20 -0500 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2012-06-25 22:31:20 -0500 |
commit | 614f4c61d0e7f7db08b3483aa36606309dbbc9ad (patch) | |
tree | e573636ff12ad34939a55cff44409ef702ed996a | |
parent | d437b509e75970089d5d9cdd853cdcda0dc7024e (diff) |
Got readfile working.
-rw-r--r-- | src/clojure/foofs/localbackend.clj | 10 | ||||
-rw-r--r-- | src/clojure/foofs/storage/scheduler.clj | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/clojure/foofs/localbackend.clj b/src/clojure/foofs/localbackend.clj index 4f7537a..cecc77d 100644 --- a/src/clojure/foofs/localbackend.clj +++ b/src/clojure/foofs/localbackend.clj @@ -86,7 +86,7 @@ "Execute a synchronous read of a file." [scheduler salt {:keys [block-list block-size n k] :as file} offset size] (let [start-blockid (quot offset block-size) - end-blockid (quot (+ size offset) block-size) ;; one past the last + end-blockid (inc (quot (+ size offset -1) block-size)) ;; one past block-count (- end-blockid start-blockid) blocks (take block-count (drop start-blockid block-list)) blocking-queue (LinkedBlockingQueue.)] @@ -95,11 +95,9 @@ #(.put blocking-queue [block %]))) (loop [fetched-blocks {}] (if (= block-count (count fetched-blocks)) - (drop (rem offset block-size) - (take size - (flatten - (for [block blocks] - (get fetched-blocks block))))) + (take size (drop (rem offset block-size) + (apply concat (for [block blocks] + (get fetched-blocks block))))) (let [[block block-bytes] (.take blocking-queue)] (if (nil? block-bytes) errno-io diff --git a/src/clojure/foofs/storage/scheduler.clj b/src/clojure/foofs/storage/scheduler.clj index ee161ed..ed45c39 100644 --- a/src/clojure/foofs/storage/scheduler.clj +++ b/src/clojure/foofs/storage/scheduler.clj @@ -31,10 +31,10 @@ (let [[e-hash e-key] block e-block (read-block e-hash block-size n k) test-hash (sha-512 e-block)] - (if (= e-hash test-hash) + (if (= (seq e-hash) (seq test-hash)) (let [f-block (decode-block e-block e-key salt) test-hash (sha-512 f-block)] - (if (= e-key test-hash) + (if (= (seq e-key) (seq test-hash)) (continuation! f-block) (continuation! nil))) (continuation! nil))))))) |