record: prevent recordDeleteAfter from deleting current segment (#4331)

This commit is contained in:
Alessandro Ros 2025-03-16 12:24:40 +01:00 committed by GitHub
parent 3d16cf40b4
commit b64650ca4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -423,6 +423,14 @@ func TestConfErrors(t *testing.T) {
" recordPath: invalid\n",
`record path 'invalid' is missing one of the mandatory elements: %path %Y %m %d %H %M %S %f`,
},
{
"invalid record delete after",
"paths:\n" +
" my_path:\n" +
" recordSegmentDuration: 30m\n" +
" recordDeleteAfter: 20m\n",
`'recordDeleteAfter' cannot be lower than 'recordSegmentDuration'`,
},
} {
t.Run(ca.name, func(t *testing.T) {
tmpf, err := createTempFile([]byte(ca.conf))

View file

@ -512,6 +512,10 @@ func (pconf *Path) validate(
return fmt.Errorf("maximum segment duration is 1 day")
}
if pconf.RecordDeleteAfter != 0 && pconf.RecordDeleteAfter < pconf.RecordSegmentDuration {
return fmt.Errorf("'recordDeleteAfter' cannot be lower than 'recordSegmentDuration'")
}
// Authentication (deprecated)
if deprecatedCredentialsMode {