MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / Delete

Method Delete

internal/store/gitstore.go:385–415  ·  view source on GitHub ↗

Delete removes the auth file.

(_ context.Context, id string)

Source from the content-addressed store, hash-verified

383
384// Delete removes the auth file.
385func (s *GitTokenStore) Delete(_ context.Context, id string) error {
386 id = strings.TrimSpace(id)
387 if id == "" {
388 return fmt.Errorf("auth filestore: id is empty")
389 }
390 path, err := s.resolveDeletePath(id)
391 if err != nil {
392 return err
393 }
394 if err = s.EnsureRepository(); err != nil {
395 return err
396 }
397
398 s.mu.Lock()
399 defer s.mu.Unlock()
400
401 if err = os.Remove(path); err != nil && !os.IsNotExist(err) {
402 return fmt.Errorf("auth filestore: delete failed: %w", err)
403 }
404 if err == nil {
405 rel, errRel := s.relativeToRepo(path)
406 if errRel != nil {
407 return errRel
408 }
409 messageID := id
410 if errCommit := s.commitAndPushLocked(fmt.Sprintf("Delete auth %s", messageID), rel); errCommit != nil {
411 return errCommit
412 }
413 }
414 return nil
415}
416
417// PersistAuthFiles commits and pushes the provided paths to the remote repository.
418// It no-ops when the store is not fully configured or when there are no paths.

Callers

nothing calls this directly

Calls 5

resolveDeletePathMethod · 0.95
EnsureRepositoryMethod · 0.95
relativeToRepoMethod · 0.95
commitAndPushLockedMethod · 0.95
RemoveMethod · 0.80

Tested by

no test coverage detected