autofile: ensure file is open in Sync

This commit is contained in:
Ethan Buchman
2017-10-02 14:17:16 -04:00
parent 9997e3a3b4
commit 0948343a6f

View File

@@ -103,6 +103,11 @@ func (af *AutoFile) Sync() error {
af.mtx.Lock()
defer af.mtx.Unlock()
if af.file == nil {
if err := af.openFile(); err != nil {
return err
}
}
return af.file.Sync()
}