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

Method PersistConfig

internal/store/objectstore.go:319–334  ·  view source on GitHub ↗

PersistConfig uploads the local configuration file to the object storage backend.

(ctx context.Context)

Source from the content-addressed store, hash-verified

317
318// PersistConfig uploads the local configuration file to the object storage backend.
319func (s *ObjectTokenStore) PersistConfig(ctx context.Context) error {
320 s.mu.Lock()
321 defer s.mu.Unlock()
322
323 data, err := os.ReadFile(s.configPath)
324 if err != nil {
325 if errors.Is(err, fs.ErrNotExist) {
326 return s.deleteObject(ctx, objectStoreConfigKey)
327 }
328 return fmt.Errorf("object store: read config file: %w", err)
329 }
330 if len(data) == 0 {
331 return s.deleteObject(ctx, objectStoreConfigKey)
332 }
333 return s.putObject(ctx, objectStoreConfigKey, data, "application/x-yaml")
334}
335
336func (s *ObjectTokenStore) ensureBucket(ctx context.Context) error {
337 exists, err := s.client.BucketExists(ctx, s.cfg.Bucket)

Callers

nothing calls this directly

Calls 2

deleteObjectMethod · 0.95
putObjectMethod · 0.95

Tested by

no test coverage detected