guard the conversion

pull/20101/head
cskh 2024-01-05 13:36:28 -05:00
parent 0956e061b6
commit ed9709a578
1 changed files with 8 additions and 5 deletions

View File

@ -4669,12 +4669,15 @@ func (a *Agent) persistServerMetadata() {
continue
}
sf := f.(*safeio.File)
if err := sf.Commit(); err != nil {
a.logger.Error("failed to commit server metadata", "error", err)
continue
// Use safeio.File to ensure the file is written to disk atomically
if sf, ok := f.(*safeio.File); ok {
if err := sf.Commit(); err != nil {
sf.Close()
a.logger.Error("failed to commit server metadata", "error", err)
continue
}
}
sf.Close()
f.Close()
case <-a.shutdownCh:
return
}