Skip to content

Commit

Permalink
create Init method
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Feb 10, 2024
1 parent d72db8a commit 12ede06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"fmt"
"os"
"path"
"path/filepath"
"reflect"
"slices"
Expand Down Expand Up @@ -861,11 +860,7 @@ func (p *Profile) Schedules() []*Schedule {
Flags: map[string]string{},
}

if len(config.Log) > 0 {
if tempDir, err := util.TempDir(); err == nil && strings.HasPrefix(config.Log, filepath.ToSlash(tempDir)) {
config.Log = path.Join(constants.TemporaryDirMarker, config.Log[len(tempDir):])
}
}
config.Init(p.config)

configs = append(configs, config)
}
Expand Down
13 changes: 13 additions & 0 deletions config/schedule.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package config

import (
"path"
"path/filepath"
"strings"
"time"

"github.com/creativeprojects/resticprofile/constants"
"github.com/creativeprojects/resticprofile/util"
)

type ScheduleLockMode int8
Expand Down Expand Up @@ -46,6 +50,15 @@ func NewEmptySchedule(profileName, command string) *Schedule {
}

Check warning on line 50 in config/schedule.go

View check run for this annotation

Codecov / codecov/patch

config/schedule.go#L46-L50

Added lines #L46 - L50 were not covered by tests
}

func (s *Schedule) Init(config *Config, profiles ...*Profile) {
// temporary log file
if s.Log != "" {
if tempDir, err := util.TempDir(); err == nil && strings.HasPrefix(s.Log, filepath.ToSlash(tempDir)) {
s.Log = path.Join(constants.TemporaryDirMarker, s.Log[len(tempDir):])
}
}
}

func (s *Schedule) GetLockMode() ScheduleLockMode {
switch s.LockMode {
case constants.ScheduleLockModeOptionFail:
Expand Down

0 comments on commit 12ede06

Please sign in to comment.