Skip to content

Commit

Permalink
rm pointer of backuop output
Browse files Browse the repository at this point in the history
Signed-off-by: Anisur Rahman <[email protected]>
  • Loading branch information
anisurrahman75 committed Jan 3, 2025
1 parent 5c96785 commit 7c5e23a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/restic/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

// RunBackup takes backup, cleanup old snapshots, check repository integrity etc.
// It extracts valuable information from respective restic command it runs and return them for further use.
func (w *ResticWrapper) RunBackup(backupOption BackupOptions) ([]*BackupOutput, error) {
func (w *ResticWrapper) RunBackup(backupOption BackupOptions) ([]BackupOutput, error) {
// Start clock to measure total session duration
startTime := time.Now()
var backupOutput []*BackupOutput
var backupOutput []BackupOutput

// Run backup
hostStats, err := w.runBackup(backupOption)
Expand All @@ -45,7 +45,7 @@ func (w *ResticWrapper) RunBackup(backupOption BackupOptions) ([]*BackupOutput,
hostStat.StartTime = &st
hostStat.EndTime = &et
}
backupOutput = append(backupOutput, &BackupOutput{
backupOutput = append(backupOutput, BackupOutput{
Stats: []HostBackupStats{hostStat},
})
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func (w *ResticWrapper) updateElapsedTimeout(startTime time.Time) {

// RunParallelBackup runs multiple backup in parallel.
// Host must be different for each backup.
func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConcurrency int) ([]*[]*BackupOutput, error) {
func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConcurrency int) ([][]BackupOutput, error) {
// WaitGroup to wait until all go routine finishes
wg := sync.WaitGroup{}
// concurrencyLimiter channel is used to limit maximum number simultaneous go routine
Expand All @@ -135,7 +135,7 @@ func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConc
mu sync.Mutex // use lock to avoid racing condition
)

var multipleOutputs []*[]*BackupOutput
var multipleOutputs [][]BackupOutput
for i := range backupOptions {
// try to send message in concurrencyLimiter channel.
// if maximum allowed concurrent backup is already running, program control will get stuck here.
Expand All @@ -155,7 +155,7 @@ func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConc
// sh field in ResticWrapper is a pointer. we must not use same w in multiple go routine.
// otherwise they might enter in racing condition.
nw := w.Copy()
var backupOutputs []*BackupOutput
var backupOutputs []BackupOutput
hostStats, err := nw.runBackup(opt)
for _, hostStat := range hostStats {
if err != nil {
Expand All @@ -172,7 +172,7 @@ func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConc
hostStat.StartTime = &st
hostStat.EndTime = &et
}
backupOutput := &BackupOutput{
backupOutput := BackupOutput{
Stats: []HostBackupStats{hostStat},
}
mu.Lock()
Expand All @@ -181,7 +181,7 @@ func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, maxConc
backupOutputs = append(backupOutputs, backupOutput)
mu.Unlock()
}
multipleOutputs = append(multipleOutputs, &backupOutputs)
multipleOutputs = append(multipleOutputs, backupOutputs)
}(backupOptions[i], time.Now())
}

Expand Down

0 comments on commit 7c5e23a

Please sign in to comment.