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