Explorar o código

Close tmpfiles earlier (ref #2)

Jakob Borg %!s(int64=12) %!d(string=hai) anos
pai
achega
c549e413a2
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      model_puller.go

+ 2 - 2
model_puller.go

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