Skip to content

Commit

Permalink
fix NPE on empty -times.csv #15 #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Kamenarsky committed Feb 22, 2012
1 parent 82e7bb3 commit d1b4059
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject atea "1.0.2"
(defproject atea "1.0.3"
:description "Minimalistic time tracker for MacOS"
:dependencies [[org.clojure/clojure "1.3.0"]]
:native-dependencies [[org.clojars.pka/jdic-macos-tray "0.0.2"]]
Expand Down
13 changes: 6 additions & 7 deletions src/tracker/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@

(defn load-ttasks [file]
(try
(let [lines (string/split-lines (slurp file))
status (parse-status (first lines))]
(let [lines (filter (comp not empty?) (string/split-lines (slurp file)))
status (when (first lines) (parse-status (first lines)))]
(if status
{:active status
:ttasks (or (map parse-ttask (next lines)) [])}
:ttasks (map parse-ttask (next lines))}
{:active nil
:ttasks (or (map parse-ttask lines) [])}))
:ttasks (map parse-ttask lines)}))
(catch java.io.FileNotFoundException e
{:active nil
:ttasks []})))
Expand Down Expand Up @@ -196,9 +196,8 @@
kts))

; get active time
tactive (if new-active
(assoc new-active :time (get-in kts [(key-task new-active) :time] 0))
nil)
tactive (when new-active
(assoc new-active :time (get-in kts [(key-task new-active) :time] 0)))

; write lines
lines (map write-ttask tmerged)
Expand Down

0 comments on commit d1b4059

Please sign in to comment.