Skip to content

Commit

Permalink
refactor(do_backup/do_backup_v2): Move sleep to helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Jul 29, 2022
1 parent 9986f45 commit e4136a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions do_backup/do_backup_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func DoBackupV2(
var data io.ReadSeeker
var stdErr string

if b.SleepBefore != 0 && i != 0 {
logSleepStart(tel, b)
time.Sleep(time.Duration(b.SleepBefore) * time.Second)
logSleepDone(tel, b)
}
sleep(b, tel, i)

// Backup source
logBackupStart(tel, b)
Expand Down
16 changes: 16 additions & 0 deletions do_backup/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package do_backup

import (
"time"

"github.com/sikalabs/tergum/backup"
"github.com/sikalabs/tergum/telemetry"
)

func sleep(b backup.Backup, tel telemetry.Telemetry, i int) {
if b.SleepBefore != 0 && i != 0 {
logSleepStart(tel, b)
time.Sleep(time.Duration(b.SleepBefore) * time.Second)
logSleepDone(tel, b)
}
}

0 comments on commit e4136a1

Please sign in to comment.