feat: improve security
This commit is contained in:
parent
99fb97dff3
commit
5b16cef525
8 changed files with 181 additions and 46 deletions
10
store.go
10
store.go
|
|
@ -113,7 +113,7 @@ func (ts *TimeStore) stopCurrentEntry(now time.Time) (bool, error) {
|
|||
return rowsAffected > 0, nil
|
||||
}
|
||||
|
||||
func (ts *TimeStore) StartTracking(tag string, withoutTimew bool) error {
|
||||
func (ts *TimeStore) StartTracking(tag string) error {
|
||||
if tag == "" {
|
||||
return fmt.Errorf("cannot start tracking with an empty tag")
|
||||
}
|
||||
|
|
@ -126,9 +126,6 @@ func (ts *TimeStore) StartTracking(tag string, withoutTimew bool) error {
|
|||
if stopped {
|
||||
slog.Info("Stopped previous time entry.")
|
||||
}
|
||||
if !withoutTimew {
|
||||
runCommand("timew", "start", "work")
|
||||
}
|
||||
|
||||
query := `INSERT INTO time_entries (tag, start_time, end_time) VALUES (?, ?, NULL);`
|
||||
_, err = ts.db.Exec(query, tag, now)
|
||||
|
|
@ -139,15 +136,12 @@ func (ts *TimeStore) StartTracking(tag string, withoutTimew bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ts *TimeStore) StopTracking(withoutTimew bool) error {
|
||||
func (ts *TimeStore) StopTracking() error {
|
||||
now := time.Now()
|
||||
stopped, err := ts.stopCurrentEntry(now)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !withoutTimew {
|
||||
runCommand("timew", "stop", "work")
|
||||
}
|
||||
if stopped {
|
||||
slog.Info(fmt.Sprintf("Stopped tracking at %s", now.Format(time.RFC3339)))
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue