fix zombie leak, add quiet-hours toggle, improve query reply, configurable router threshold, JS dashboard
This commit is contained in:
@@ -36,7 +36,10 @@ func (s *Store) WriteFact(ctx context.Context, ts time.Time, kind FactKind, key,
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("write fact: %w", err)
|
||||
}
|
||||
id, _ := res.LastInsertId()
|
||||
id, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("last insert id: %w", err)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
@@ -156,7 +159,10 @@ func (s *Store) CorrectValue(ctx context.Context, key, source string, value any,
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
newID, _ = res.LastInsertId()
|
||||
newID, err = res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("last insert id: %w", err)
|
||||
}
|
||||
return newID, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,10 @@ func (s *Store) WriteNote(ctx context.Context, ts time.Time, text string, embedd
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("write note: %w", err)
|
||||
}
|
||||
id, _ := res.LastInsertId()
|
||||
id, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("last insert id: %w", err)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,9 @@ func Open(ctx context.Context, path string) (*Store, error) {
|
||||
// single writer expected; the daemon is the only process touching the db.
|
||||
db.SetMaxOpenConns(1)
|
||||
if _, err := db.ExecContext(ctx, schemaSQL); err != nil {
|
||||
_ = db.Close()
|
||||
if closeErr := db.Close(); closeErr != nil {
|
||||
return nil, fmt.Errorf("apply schema: %w (close: %v)", err, closeErr)
|
||||
}
|
||||
return nil, fmt.Errorf("apply schema: %w", err)
|
||||
}
|
||||
return &Store{db: db}, nil
|
||||
|
||||
Reference in New Issue
Block a user