From 0948343a6fd4efce07894c312d8e96c5f277c608 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 2 Oct 2017 14:17:16 -0400 Subject: [PATCH] autofile: ensure file is open in Sync --- autofile/autofile.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autofile/autofile.go b/autofile/autofile.go index 5d6bc7261..05fb0d677 100644 --- a/autofile/autofile.go +++ b/autofile/autofile.go @@ -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() }