MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / Delete

Method Delete

internal/instructions/store.go:362–388  ·  view source on GitHub ↗

Delete uninstalls every install, removes the managed file, and deletes rows.

(ctx context.Context, id int64)

Source from the content-addressed store, hash-verified

360
361// Delete uninstalls every install, removes the managed file, and deletes rows.
362func (s *Store) Delete(ctx context.Context, id int64) error {
363 if err := s.Init(ctx); err != nil {
364 return err
365 }
366 db, err := s.open()
367 if err != nil {
368 return err
369 }
370 defer db.Close()
371
372 current, err := getTx(ctx, db, id)
373 if err != nil {
374 return err
375 }
376
377 for _, ins := range current.Installs {
378 removeInstalledFile(ins, managedFilePath(current.Name))
379 }
380 if _, err := db.ExecContext(ctx, `DELETE FROM instruction_installs WHERE instruction_id = ?`, id); err != nil {
381 return fmt.Errorf("instructions: delete installs: %w", err)
382 }
383 if _, err := db.ExecContext(ctx, `DELETE FROM instructions WHERE id = ?`, id); err != nil {
384 return fmt.Errorf("instructions: delete: %w", err)
385 }
386 os.Remove(managedFilePath(current.Name))
387 return nil
388}
389
390// retargetSymlink replaces the symlink at target so it points at newSrc.
391func retargetSymlink(target, newSrc string) {

Callers 2

TestCRUDRoundTripFunction · 0.45

Calls 6

InitMethod · 0.95
openMethod · 0.95
getTxFunction · 0.85
removeInstalledFileFunction · 0.85
managedFilePathFunction · 0.85
RemoveMethod · 0.45

Tested by 2

TestCRUDRoundTripFunction · 0.36