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 continue
} }
sf := f.(*safeio.File) // 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 { if err := sf.Commit(); err != nil {
sf.Close()
a.logger.Error("failed to commit server metadata", "error", err) a.logger.Error("failed to commit server metadata", "error", err)
continue continue
} }
sf.Close() }
f.Close()
case <-a.shutdownCh: case <-a.shutdownCh:
return return
} }