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

Method uploadAuth

internal/store/objectstore.go:449–469  ·  view source on GitHub ↗
(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

447}
448
449func (s *ObjectTokenStore) uploadAuth(ctx context.Context, path string) error {
450 if path == "" {
451 return nil
452 }
453 rel, err := filepath.Rel(s.authDir, path)
454 if err != nil {
455 return fmt.Errorf("object store: resolve auth relative path: %w", err)
456 }
457 data, err := os.ReadFile(path)
458 if err != nil {
459 if errors.Is(err, fs.ErrNotExist) {
460 return s.deleteAuthObject(ctx, path)
461 }
462 return fmt.Errorf("object store: read auth file: %w", err)
463 }
464 if len(data) == 0 {
465 return s.deleteAuthObject(ctx, path)
466 }
467 key := objectStoreAuthPrefix + "/" + filepath.ToSlash(rel)
468 return s.putObject(ctx, key, data, "application/json")
469}
470
471func (s *ObjectTokenStore) deleteAuthObject(ctx context.Context, path string) error {
472 if path == "" {

Callers 2

SaveMethod · 0.95
PersistAuthFilesMethod · 0.95

Calls 2

deleteAuthObjectMethod · 0.95
putObjectMethod · 0.95

Tested by

no test coverage detected