Close go-git repository handles across store operations and tests to avoid
leaked handles blocking recovery cleanup. Abort recovery before mutating the
worktree when close failures occur and retain backups when rollback fails.
- Added safeguards against repository corruption with improved recovery mechanisms, including remote re-cloning and worktree restoration.
- Introduced fine-grained repository integrity checks and missing file restoration logic.
- Centralized repository locking with `ensureRepositoryLocked` to standardize synchronization.
- Enhanced conflict resolution during pulls with automated reconciliation of remote and local changes.
- Improved worktree and index reset workflows to handle dirty and missing paths gracefully.
- Increased robustness for garbage collection with extended grace period and recovery paths.
Closes: #4629
- Added support for weighted round-robin authentication scheduling strategy.
- Implemented credential weight validation for attributes and metadata, with strict error handling for invalid weights.
- Enhanced scheduler with smooth weighted state handling and proportional selection logic.
- Introduced tests for credential weight parsing, validation, and weighted round-robin behavior.
- Updated configuration to include `weight` field for credentials with range validation.
Closes: #4470
- Introduced `PostgresCooldownStateStore` for saving and loading cooldown states in a PostgreSQL database.
- Supported runtime cooldown state management with efficient upsert and deletion.
- Added configurable integration via `PostgresStoreConfig` and updated schema management to include cooldown-related tables.
- Included tests to validate persistence, normalization, and concurrent handling of cooldown state records.
- Enabled overriding cooldown state stores via service builder and SDK configuration.
Closes: #4254
- Updated git operations to leverage `ClientOptions` for authentication and configuration, replacing the deprecated `AuthMethod`.
- Implemented logic to disable GPG commit signing in repositories to prevent signature errors in automated workflows.
- Upgraded dependencies in `go.mod` and `go.sum` to align with the latest `github.com/go-git/go-git/v6` alpha releases.
- Added unit tests to verify commit signing is properly disabled in repositories.
Closes: #4341
- Introduced `AuthKind` and `AuthSourceKind` methods for improved credential type and source classification.
- Replaced legacy fallback logic with normalized attribute-based handling in `AuthKind`.
- Consolidated metadata inspection for both API key and OAuth attributes.
- Updated calls to replace direct `AccountInfo` usage with `AuthKind` and `AuthSourceKind`.
- Enhanced unit tests to validate explicit and fallback credential resolution scenarios.
- Updated `maybeRunGC` to accept `repoDir` instead of `repo`.
- Moved garbage collection trigger to occur after the push step for improved reliability.
- Added a test to validate the sequence of push and GC operations.
Closes: #3373
- Added logic to set `auth.Disabled` and update `auth.Status` to `StatusDisabled` when `disabled` metadata is provided and true.
- Updated `objectstore`, `gitstore`, and `postgresstore` implementations to handle the new metadata attribute.
Closes: #2651
- Updated `FileTokenStore` and related stores (`objectstore`, `gitstore`, `postgresstore`) to include the `disabled` flag in metadata for token storage.
- Adjusted `Auth` metadata handling to initialize empty maps when absent.
- Refined logic in `auto_refresh_loop` and `conductor` to exclude `disabled` tokens from refresh checks.
- Added comprehensive unit tests to verify proper handling of the `disabled` flag in storage and retrieval operations.
- Updated all references from v6 to v7 for `github.com/router-for-me/CLIProxyAPI`.
- Ensured consistency in imports within core libraries, tests, and integration tests.
- Added missing tests for new features in Redis Protocol integration.
Remove os.RemoveAll() call in syncAuthFromBucket() that was causing
a race condition with the file watcher.
Problem:
1. syncAuthFromBucket() wipes local auth directory with RemoveAll
2. File watcher detects deletions and propagates them to remote store
3. syncAuthFromBucket() then pulls from remote, but files are now gone
Solution:
Use incremental sync instead of delete-then-pull. Just ensure the
directory exists and overwrite files as they're downloaded.
This prevents the watcher from seeing spurious delete events.
- Added `GitTokenStore` to handle token storage and metadata using Git as a backing storage.
- Implemented methods for initialization, save, retrieval, listing, and deletion of auth files.
- Updated `go.mod` and `go.sum` to include new dependencies for Git integration.
- Integrated support for Git-backed configuration via `GitTokenStore`.
- Updated server logic to clone, initialize, and manage configurations from Git repositories.
- Added helper functions for verifying and synchronizing configuration files.
- Improved error handling and contextual logging for Git operations.
- Modified Dockerfile to include `config.example.yaml` for initial setup.
- Added `gitCommitter` interface to handle Git-based commit and push operations.
- Configured `Watcher` to detect and leverage Git-backed token stores.
- Implemented `commitConfigAsync` and `commitAuthAsync` methods for asynchronous change synchronization.
- Enhanced `GitTokenStore` with `CommitPaths` method to support selective file commits.