Skip to content

Commit

Permalink
Avoid reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
totakke committed Apr 1, 2014
1 parent b9bd76e commit 0635480
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/cavia/downloader.clj
Expand Up @@ -64,16 +64,15 @@
(ftp/with-ftp [ftp-client host :file-type :binary]
(.setSoTimeout ftp-client 30000)
(.setDataTimeout ftp-client 30000)
(let [content-len (.. ftp-client (mlistFile path) getSize)
is (ftp/client-get-stream ftp-client path)]
(with-open [os (io/output-stream f)]
(download! is os content-len))
(.close is)
(try
(ftp/client-complete-pending-command ftp-client)
(catch java.net.SocketTimeoutException e
;; NOTE: `client-complete-pending-command` sometimes hangs after
;; downloading a large file. But the file is fine and the
;; downloading process succeded to finish. Therefore here
;; ignores the timeout.
nil))))))
(let [content-len (.. ftp-client (mlistFile path) getSize)]
(with-open [is ^InputStream (ftp/client-get-stream ftp-client path)
os (io/output-stream f)]
(download! is os content-len)))
(try
(ftp/client-complete-pending-command ftp-client)
(catch java.net.SocketTimeoutException e
;; NOTE: `client-complete-pending-command` sometimes hangs after
;; downloading a large file. But the file is fine and the
;; downloading process succeded to finish. Therefore here
;; ignores the timeout.
nil)))))

0 comments on commit 0635480

Please sign in to comment.