Skip to content

Commit

Permalink
Fix pending downloads not showing issue, use more idiomatic atom swap…
Browse files Browse the repository at this point in the history
…ping, bump to version 0.0.9
  • Loading branch information
verma committed Feb 25, 2014
1 parent bd1700c commit e4f71f4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ You create tags (pretty looking names for local directories) and tag your remote

Current Release
---
Current release version is `0.0.8`. It will do what its supposed to do, but it has a long way to go.
Current release version is `0.0.9`. It will do what its supposed to do, but it has a long way to go.

[Download Now](https://github.com/verma/dakait/releases/download/0.0.8/dakait-0.0.8-standalone.jar)
[Download Now](https://github.com/verma/dakait/releases/download/0.0.9/dakait-0.0.9-standalone.jar)

How to run
---
Expand All @@ -19,7 +19,7 @@ You need a configuration file to run Dakait. Modify and rename `config.example.

Once you have the jar file, make sure your server has a recent enough version of java. You can start the server by running the following command

java -jar dakait-0.0.8-standalone.jar
java -jar dakait-0.0.9-standalone.jar

This will start a server and bind to port `3000`. Now point your browser to `http://server-address:3000/`

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject dakait "0.0.8"
(defproject dakait "0.0.9"
:description "A tool to download files from your FTP/SFTP servers in an organized way."
:url "https://github.com/verma/dakait"
:dependencies [[org.clojure/clojure "1.5.1"]
Expand Down
2 changes: 1 addition & 1 deletion src-cljs/index/start.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
cd ($ ".current-downloads")
nd ($ ".nodownloads")
active (.-active data)
queued (.-pending data)
pending (.-pending data)
num-items (count active)
filename #(->> (clojure.string/split % #"/")
(remove empty?)
Expand Down
5 changes: 2 additions & 3 deletions src/dakait/downloader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
(let [state-map (update-to-map line)]
(info "source key: " src)
(info "download state map: " state-map)
(reset! download-states
(assoc @download-states src state-map)))))
(swap! download-states assoc src state-map))))
(info "Process ended")
(sh/exit-code p))
(catch Exception e
Expand Down Expand Up @@ -153,7 +152,7 @@
"Start a download for the given file"
[src dest]
(info "Queuing download, source: " src ", destination: " dest)
(reset! download-queue (conj @download-queue [src dest])))
(swap! download-queue conj [src dest]))

(defn run
"Run the downloader loop"
Expand Down
22 changes: 12 additions & 10 deletions src/dakait/files.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@
session invalidation is reset, when the reset invalidation expires the ssh session is
invalidated and set to nil"
[]
(when-not (nil? @session-invalidator)
(future-cancel @session-invalidator))
(reset! session-invalidator
(future
(Thread/sleep 120000)
(info "Invalidating session")
(let [s @ssh-session]
(reset! ssh-session nil)
(reset! session-invalidator nil)
(ssh/disconnect s)))))
(swap! session-invalidator
(fn [si]
(when-not (nil? si)
(future-cancel si))
(future
(Thread/sleep 120000)
(info "Invalidating session")
(swap! ssh-session (fn [s]
(ssh/disconnect s)
nil))
(reset! session-invalidator nil)))))


(defn- session []
"Get the currently active session, if one doesn't exist, create a new one and make sure the
Expand Down
10 changes: 0 additions & 10 deletions src/dakait/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@
(as-json {:active (downloads-in-progress)
:pending (map (fn [d] {:from (first d) :to (second d)}) (downloads-pending))}))

(defn handle-active-downloads2 []
(as-json {:active [{:from "/some/really/long/path/and/then/the/longest/path/ever/seriously" :to "/some/really/really/really/really/long path"}
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}]
:pending [
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}
{:from "/some/really/long/path" :to "/some/really/really/really/really/long path"}]}))

(defroutes app-routes
(GET "/" [] (index-page))
(GET "/tags" [] (tags-page))
Expand Down

0 comments on commit e4f71f4

Please sign in to comment.