aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clojure/foofs/localbackend.clj10
-rw-r--r--src/clojure/foofs/storage/scheduler.clj4
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)))))))