Delete removes an auth file and the corresponding database record.
(ctx context.Context, id string)
| 337 | |
| 338 | // Delete removes an auth file and the corresponding database record. |
| 339 | func (s *PostgresStore) Delete(ctx context.Context, id string) error { |
| 340 | id = strings.TrimSpace(id) |
| 341 | if id == "" { |
| 342 | return fmt.Errorf("postgres store: id is empty") |
| 343 | } |
| 344 | path, err := s.resolveDeletePath(id) |
| 345 | if err != nil { |
| 346 | return err |
| 347 | } |
| 348 | |
| 349 | s.mu.Lock() |
| 350 | defer s.mu.Unlock() |
| 351 | |
| 352 | if err = os.Remove(path); err != nil && !errors.Is(err, fs.ErrNotExist) { |
| 353 | return fmt.Errorf("postgres store: delete auth file: %w", err) |
| 354 | } |
| 355 | relID, err := s.relativeAuthID(path) |
| 356 | if err != nil { |
| 357 | return err |
| 358 | } |
| 359 | return s.deleteAuthRecord(ctx, relID) |
| 360 | } |
| 361 | |
| 362 | // PersistAuthFiles stores the provided auth file changes in PostgreSQL. |
| 363 | func (s *PostgresStore) PersistAuthFiles(ctx context.Context, _ string, paths ...string) error { |
nothing calls this directly
no test coverage detected