diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 81289aa7..540abdaf 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -281,6 +281,15 @@ func TestConfErrors(t *testing.T) { " ~^.*$:\n", `all_others, all and '~^.*$' are aliases`, }, + { + "playback", + "playback: yes\n" + + "paths:\n" + + " my_path:\n" + + " recordPath: ./recordings/%path/%Y-%m-%d_%H-%M-%S", + `record path './recordings/%path/%Y-%m-%d_%H-%M-%S' is missing one of the` + + ` mandatory elements for the playback server to work: %Y %m %d %H %M %S %f`, + }, } { t.Run(ca.name, func(t *testing.T) { tmpf, err := createTempFile([]byte(ca.conf)) diff --git a/internal/conf/path.go b/internal/conf/path.go index 93a7eefd..042eae22 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -378,6 +378,22 @@ func (pconf *Path) validate( } } + // Record + + if conf.Playback { + if !strings.Contains(pconf.RecordPath, "%Y") || + !strings.Contains(pconf.RecordPath, "%m") || + !strings.Contains(pconf.RecordPath, "%d") || + !strings.Contains(pconf.RecordPath, "%H") || + !strings.Contains(pconf.RecordPath, "%M") || + !strings.Contains(pconf.RecordPath, "%S") || + !strings.Contains(pconf.RecordPath, "%f") { + return fmt.Errorf("record path '%s' is missing one of the mandatory elements"+ + " for the playback server to work: %%Y %%m %%d %%H %%M %%S %%f", + pconf.RecordPath) + } + } + // Authentication (deprecated) if deprecatedCredentialsMode {