raise an error in case recordPath is incompatible with the playback server (#3356)

This commit is contained in:
Alessandro Ros 2024-05-14 17:40:45 +02:00 committed by GitHub
parent 6debb52abd
commit c0ad6e4dc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -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))

View File

@ -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 {