Permalink
Browse files

fix NPE on empty -times.csv #15 #18

  • Loading branch information...
1 parent 82e7bb3 commit d1b4059736ffe0dc0f26bfe7ca7719468cf280b1 Philip Kamenarsky committed Feb 22, 2012
Showing with 7 additions and 8 deletions.
  1. +1 −1 project.clj
  2. +6 −7 src/tracker/core.clj
View
@@ -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"]]
View
@@ -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 []})))
@@ -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)

0 comments on commit d1b4059

Please sign in to comment.