mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-05 16:12:20 +00:00
Close tmpfiles earlier (ref #2)
This commit is contained in:
parent
63a05ff6fa
commit
c549e413a2
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user