Skip to content

Commit

Permalink
Handle error from the file watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
naspeh committed Apr 25, 2024
1 parent 55cc22f commit 04d2680
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions timefor.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ func Daemon(
select {
case c := <-change:
log.Println("change", c)
if c.Error != nil {
return c.Error
}

case <-time.After(nextUpdate):
if activity.Active() && time.Since(activity.Updated()) > time.Minute {
Expand Down Expand Up @@ -680,14 +683,6 @@ func Report(db *sqlx.DB) (title, desc string, err error) {
return title, buf.String(), nil
}

func formatDuration(d time.Duration) string {
d = d.Truncate(time.Minute)
h := d / time.Hour
d -= h * time.Hour
m := d / time.Minute
return fmt.Sprintf("%02d:%02d", h, m)
}

// Select selects new activity using rofi menu
func Select(db *sqlx.DB) (string, error) {
var names []string
Expand Down Expand Up @@ -726,6 +721,14 @@ func Select(db *sqlx.DB) (string, error) {
return string(selectedName), nil
}

func formatDuration(d time.Duration) string {
d = d.Truncate(time.Minute)
h := d / time.Hour
d -= h * time.Hour
m := d / time.Minute
return fmt.Sprintf("%02d:%02d", h, m)
}

// Activity represents a named activity
type Activity struct {
ID int64
Expand Down

0 comments on commit 04d2680

Please sign in to comment.