mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
catch errors on closing written-to files
This commit is contained in:
parent
3cea9d28f6
commit
2742ac351c
5 changed files with 10 additions and 8 deletions
|
|
@ -1785,6 +1785,8 @@ func writeTestFile(t *testing.T, filename, content string) string {
|
|||
if err != nil {
|
||||
t.Fatalf("could not write string %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatalf("could not close file %v", err)
|
||||
}
|
||||
return fname
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ func (r *stateMachine) Upload() error {
|
|||
}
|
||||
|
||||
func UploadTar(srcFile string, client *pilosa.InternalClient, profile, host string) error {
|
||||
|
||||
f, err := os.Open(srcFile)
|
||||
if err != nil {
|
||||
return (err)
|
||||
|
|
|
|||
|
|
@ -1180,13 +1180,11 @@ func (h *Holder) logStartup() error {
|
|||
return errors.Wrap(err, "opening startup log")
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
if _, err = f.WriteString(logLine); err != nil {
|
||||
return errors.Wrap(err, "writing startup log")
|
||||
}
|
||||
|
||||
return nil
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
// holderSyncer is an active anti-entropy tool that compares the local holder
|
||||
|
|
|
|||
|
|
@ -1315,9 +1315,10 @@ func mustWritePage(tb testing.TB, path string, pgno uint32, buf []byte) {
|
|||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if _, err := f.WriteAt(buf, int64(pgno)*rbf.PageSize); err != nil {
|
||||
tb.Fatal(err)
|
||||
} else if err := f.Close(); err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1891,10 +1891,12 @@ func writeTestFile(t *testing.T, filename, content string) string {
|
|||
fname := filepath.Join(t.TempDir(), filename)
|
||||
f, err := os.Create(fname)
|
||||
if err != nil {
|
||||
panic(filename)
|
||||
t.Fatal(err)
|
||||
}
|
||||
io.WriteString(f, content)
|
||||
defer f.Close()
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return fname
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue