Skip to content

Commit 819f606

Browse files
committed
fix(schedule): omit launchd log paths when schedule-log is configured
When schedule-log is set in the profile configuration, resticprofile handles logging internally. Previously, the launchd plist always included StandardOutPath/StandardErrorPath entries pointing to <job-name>.log files, which remained empty when schedule-log was configured. This change omits those plist fields (via their omitempty tags) when schedule-log is set, avoiding the creation of empty log files.
1 parent 8ea331c commit 819f606

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

schedule/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Config struct {
2424
Flags map[string]string // flags added to the command line
2525
AfterNetworkOnline bool
2626
SystemdDropInFiles []string
27+
Log string
2728
HideWindow bool
2829
removeOnly bool
2930
}

schedule/handler_darwin.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,14 @@ func (h *HandlerLaunchd) Scheduled(profileName string) ([]Config, error) {
183183

184184
func (h *HandlerLaunchd) getLaunchdJob(job *Config, schedules []*calendar.Event) *darwin.LaunchdJob {
185185
name := getJobName(job.ProfileName, job.CommandName)
186-
// we always set the log file in the job settings as a default
187-
// if changed in the configuration via schedule-log the standard output will be empty anyway
188-
logfile := name + ".log"
186+
// Only set the log file when schedule-log is not configured.
187+
// When schedule-log is set, resticprofile handles logging internally,
188+
// so we omit StandardOutPath/StandardErrorPath from the plist to avoid
189+
// creating empty log files (the plist fields have omitempty tags).
190+
var logfile string
191+
if job.Log == "" {
192+
logfile = name + ".log"
193+
}
189194

190195
// Format schedule env, adding PATH if not yet provided by the schedule config
191196
env := util.NewDefaultEnvironment(job.Environment...)

schedule_jobs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,6 @@ func scheduleToConfig(sched *config.Schedule) *schedule.Config {
239239
AfterNetworkOnline: sched.AfterNetworkOnline.IsTrue(),
240240
SystemdDropInFiles: sched.SystemdDropInFiles,
241241
HideWindow: sched.HideWindow.IsTrue(),
242+
Log: sched.Log,
242243
}
243244
}

0 commit comments

Comments
 (0)