diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-28 10:16:18 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-28 10:16:18 +0200 |
| commit | 73c6a37ecf0aac04711e5624455743b3493a7ef5 (patch) | |
| tree | ac58cce0dcd03ccac3f5f3e313a46ebe9d352b30 /internal/cli/sync_handlers.go | |
| parent | 1615abaacccdbb5002404a77270fd333ce8ad718 (diff) | |
Diffstat (limited to 'internal/cli/sync_handlers.go')
| -rw-r--r-- | internal/cli/sync_handlers.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/cli/sync_handlers.go b/internal/cli/sync_handlers.go index 6a96b92..e791b45 100644 --- a/internal/cli/sync_handlers.go +++ b/internal/cli/sync_handlers.go @@ -12,6 +12,14 @@ import ( "codeberg.org/snonux/gitsyncer/internal/sync" ) +func shouldEnableBackupSync(flags *Flags) bool { + if flags == nil { + return false + } + + return flags.Backup || flags.FullSync +} + // HandleSync handles syncing a single repository func HandleSync(cfg *config.Config, flags *Flags) int { stateManager, syncState, err := loadSyncState(flags.WorkDir) @@ -50,7 +58,7 @@ func HandleSync(cfg *config.Config, flags *Flags) int { } syncer := sync.New(cfg, flags.WorkDir) - syncer.SetBackupEnabled(flags.Backup) + syncer.SetBackupEnabled(shouldEnableBackupSync(flags)) if err := syncer.SyncRepository(flags.SyncRepo); err != nil { fmt.Printf("ERROR: Sync failed: %v\n", err) return 1 @@ -107,7 +115,7 @@ func HandleSyncAll(cfg *config.Config, flags *Flags) int { } syncer := sync.New(cfg, flags.WorkDir) - syncer.SetBackupEnabled(flags.Backup) + syncer.SetBackupEnabled(shouldEnableBackupSync(flags)) successCount := 0 // Load descriptions cache descCache := loadDescriptionCache(flags.WorkDir) @@ -421,7 +429,7 @@ func newSyncExecution(cfg *config.Config, flags *Flags) *syncExecution { descCache: loadDescriptionCache(flags.WorkDir), syncer: sync.New(cfg, flags.WorkDir), } - execution.syncer.SetBackupEnabled(flags.Backup) + execution.syncer.SetBackupEnabled(shouldEnableBackupSync(flags)) manager, st, err := loadSyncState(flags.WorkDir) if err != nil { |
