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

Method persistConfig

internal/store/postgresstore.go:542–554  ·  view source on GitHub ↗
(ctx context.Context, data []byte)

Source from the content-addressed store, hash-verified

540}
541
542func (s *PostgresStore) persistConfig(ctx context.Context, data []byte) error {
543 query := fmt.Sprintf(`
544 INSERT INTO %s (id, content, created_at, updated_at)
545 VALUES ($1, $2, NOW(), NOW())
546 ON CONFLICT (id)
547 DO UPDATE SET content = EXCLUDED.content, updated_at = NOW()
548 `, s.fullTableName(s.cfg.ConfigTable))
549 normalized := normalizeLineEndings(string(data))
550 if _, err := s.db.ExecContext(ctx, query, defaultConfigKey, normalized); err != nil {
551 return fmt.Errorf("postgres store: upsert config: %w", err)
552 }
553 return nil
554}
555
556func (s *PostgresStore) deleteConfigRecord(ctx context.Context) error {
557 query := fmt.Sprintf("DELETE FROM %s WHERE id = $1", s.fullTableName(s.cfg.ConfigTable))

Callers 2

PersistConfigMethod · 0.95

Calls 2

fullTableNameMethod · 0.95
normalizeLineEndingsFunction · 0.85

Tested by

no test coverage detected