fix broken test for search

This commit is contained in:
Justin Kramer 2012-03-09 23:07:17 -05:00
parent 164cb0548a
commit 31e053a8ee

View file

@ -24,10 +24,10 @@
(io/file (user/leiningen-home) "indices" (string/replace url #"[:/]" "_"))) (io/file (user/leiningen-home) "indices" (string/replace url #"[:/]" "_")))
(defn remote-index-url [url] (defn remote-index-url [url]
(format "%s/.index/nexus-maven-repository-index.zip" url)) (URL. (format "%s/.index/nexus-maven-repository-index.zip" url)))
(defn- download [url ^OutputStream out-stream & {:keys [callback]}] (defn- download [^URL url ^OutputStream out-stream & {:keys [callback]}]
(let [resp (client/get url {:as :stream}) (let [resp (client/get (str url) {:as :stream})
content-len (try (Long/valueOf content-len (try (Long/valueOf
(get-in resp [:headers "content-length"])) (get-in resp [:headers "content-length"]))
(catch Exception _)) (catch Exception _))
@ -49,7 +49,7 @@
(println "Downloading index from" id "-" url "... this may take a while.") (println "Downloading index from" id "-" url "... this may take a while.")
(print "0%...") (print "0%...")
(flush) (flush)
(let [index-url (remote-index-url url) (let [index-url ^URL (remote-index-url url)
tmp (File/createTempFile "lein" "index") tmp (File/createTempFile "lein" "index")
tmp-stream (FileOutputStream. tmp) tmp-stream (FileOutputStream. tmp)
progress (atom 0) progress (atom 0)
@ -58,7 +58,9 @@
(reset! progress percentage) (reset! progress percentage)
(print (str "\r" percentage "%...")) (print (str "\r" percentage "%..."))
(flush)))] (flush)))]
(try (download index-url tmp-stream :callback callback) (try (if (= "file" (.getProtocol index-url))
(io/copy (.openStream index-url) tmp-stream)
(download index-url tmp-stream :callback callback))
(unzip tmp (index-location url)) (unzip tmp (index-location url))
(finally (.delete tmp)))) (finally (.delete tmp))))
(println)) (println))