mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-05-06 20:18:01 -05:00
[GH-ISSUE #267] Env config loader wipes backup/force-push settings on every restart #1230
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tiennm99 on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/RayLabsHQ/gitea-mirror/issues/267
Originally assigned to: @arunavo4 on GitHub.
Bug
The environment config loader (
src/lib/env-config-loader.ts) overwrites the entiregiteaConfigJSON column on every restart, but does not include any backup-related fields. This silently erases user-configured backup settings.Affected Fields
backupStrategybackupBeforeSyncbackupRetentionCountbackupRetentionDaysbackupDirectoryblockSyncOnBackupFailureRoot Cause
env-config-loader.ts:279-311builds thegiteaConfigobject without backup fields. Then at line 360, the entire column is replaced:Other fields (like
lfs,wiki,visibility) are preserved because they have?? existingConfigfallbacks in the builder. Backup fields were added later (v3.11.0) but never added to the env loader.Impact
"on-force-push"(viamapDbToUiConfigfallback)PRE_SYNC_BACKUP_STRATEGYenv var works at runtime but is never persisted to DB or shown in UI"on-force-push"regardless of actual runtime behaviorReproduction
GITEA_URL,GITEA_TOKENetc. as env vars (triggershasEnvConfig() → true)Workaround
Set
PRE_SYNC_BACKUP_STRATEGYenv var (e.g.disabled,always,on-force-push,block-on-force-push). This is read at sync time byresolveBackupStrategy()inrepo-backup.tsand takes effect because the DB field is empty. However, the UI will not reflect this value.Suggested Fix
Add backup fields to the env loader's
giteaConfigbuilder with?? existingConfigfallbacks, consistent with how other fields are handled:Optionally, also add new env vars (e.g.
BACKUP_STRATEGY) toparseEnvConfig()so users can configure backup strategy purely via env.@arunavo4 commented on GitHub (Apr 16, 2026):
@tiennm99 Thanks