MarkInstalled sets the installed flag and records the target app.
(ctx context.Context, kind, installKey, targetApp string)
| 293 | |
| 294 | // MarkInstalled sets the installed flag and records the target app. |
| 295 | func (s *Store) MarkInstalled(ctx context.Context, kind, installKey, targetApp string) error { |
| 296 | if err := s.Init(ctx); err != nil { |
| 297 | return err |
| 298 | } |
| 299 | db, err := s.open() |
| 300 | if err != nil { |
| 301 | return err |
| 302 | } |
| 303 | defer db.Close() |
| 304 | now := timeNow() |
| 305 | _, err = db.ExecContext(ctx, ` |
| 306 | UPDATE metadata_items SET installed = 1, installed_targets = ?, updated_at = ? |
| 307 | WHERE kind = ? AND install_key = ?`, targetApp, now, kind, installKey) |
| 308 | if err != nil { |
| 309 | return fmt.Errorf("metadata: mark installed: %w", err) |
| 310 | } |
| 311 | return nil |
| 312 | } |
| 313 | |
| 314 | // MarkUninstalled removes the specified app from the installed targets list. |
| 315 | // If no targets remain, the installed flag is cleared. Uses a transaction to |