      (let [path (resolve-tilde-path path)]
        (try
          (download-file-with-timeout url path timeout)
-         (catch java.io.IOException e
+         (catch java.net.SocketTimeoutException e
            (rm-rf! path)
            (Thread/sleep wait-t)
+           (when *verbose-overtone-file-helpers*
+             (println "Download timed out. Retrying:" url ))
            (download-file* url path timeout n-retries wait-t (inc attempts-made)))))))
 
 (defn- print-download-file

        con (.openConnection url)]
    (.getContentLength con)))

(defn- download-file-without-timeout
  "Downloads remote file at url to local file specified by target path. Has
  potential to block current thread whilst reading data from remote host. See

  java.net.SocketTimeoutException"
  [url target-path timeout]
  (let [target-path (resolve-tilde-path target-path)
        size        (remote-file-size url)
        url         (URL. url)
        con         (.openConnection url)]
    (.setReadTimeout con timeout)
    (with-open [in (.getInputStream con)
                out (output-stream target-path)]
      (remote-file-copy in out size))
    target-path))

(defn get-file-with-timeout
  "Returns a stringified version of the file pointed to by url. If download
  stalls for more than timeout ms an exception is thrown."
  [url timeout]
  (let [url  (URL. url)
        con  (.openConnection url)
        size (remote-file-size url)]
    (.setReadTimeout con timeout)
    (with-open [in (.getInputStream con)
                out (StringWriter.)]
      (copy in out size)
      (.toString out))))

(defn file-size
