Close tmpfiles earlier (ref #2)

This commit is contained in:
Jakob Borg 2014-01-01 16:31:52 -05:00
parent 63a05ff6fa
commit c549e413a2
1 changed files with 2 additions and 2 deletions

View File

@ -50,13 +50,13 @@ func (m *Model) pullFile(name string) error {
if err != nil { if err != nil {
return err return err
} }
defer tmpFile.Close()
contentChan := make(chan content, 32) contentChan := make(chan content, 32)
var applyDone sync.WaitGroup var applyDone sync.WaitGroup
applyDone.Add(1) applyDone.Add(1)
go func() { go func() {
applyContent(contentChan, tmpFile) applyContent(contentChan, tmpFile)
tmpFile.Close()
applyDone.Done() applyDone.Done()
}() }()
@ -196,10 +196,10 @@ func applyContent(cc <-chan content, dst io.WriterAt) error {
for c := range cc { for c := range cc {
_, err = dst.WriteAt(c.data, c.offset) _, err = dst.WriteAt(c.data, c.offset)
buffers.Put(c.data)
if err != nil { if err != nil {
return err return err
} }
buffers.Put(c.data)
} }
return nil return nil