Skip to content

Commit

Permalink
raise an error in case recordPath is incompatible with the playback s…
Browse files Browse the repository at this point in the history
…erver (#3356)
  • Loading branch information
aler9 committed May 14, 2024
1 parent 6debb52 commit c0ad6e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 16 additions & 0 deletions internal/conf/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c0ad6e4

Please sign in to comment.