diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore.clj b/blobstore/src/main/clojure/org/jclouds/blobstore.clj index 5abb6f8088..d759fd91a2 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore.clj @@ -148,8 +148,10 @@ Options can also be specified for extension modules (defn- list-blobs-chunk [container prefix #^BlobStore blobstore & [marker]] (apply list-container blobstore container - :in-directory prefix (when (string? marker) - [:after-marker marker]))) + (concat (when prefix + [:in-directory prefix]) + (when (string? marker) + [:after-marker marker])))) (defn- list-blobs-chunks [container prefix #^BlobStore blobstore marker] (when marker @@ -158,10 +160,19 @@ Options can also be specified for extension modules (list-blobs-chunks container prefix blobstore (.getNextMarker chunk))))))) +(defn- concat-elements + "Make a lazy concatenation of the lazy sequences contained in coll. Lazily evaluates coll. +Note: (apply concat coll) or (lazy-cat coll) are not lazy wrt coll itself." + [coll] + (if-let [s (seq coll)] + (lazy-seq (concat (first s) (concat-elements (next s)))))) + (defn list-blobs "Returns a lazy seq of all blobs in the given container." ([container prefix #^BlobStore blobstore] - (apply concat (list-blobs-chunks container prefix blobstore :start)))) + (concat-elements (list-blobs-chunks container prefix blobstore :start))) + ([container #^BlobStore blobstore] + (list-blobs container nil blobstore))) (defn locations "Retrieve the available container locations for the blobstore context."