mirror of
https://github.com/restic/restic.git
synced 2026-11-21 15:06:10 +00:00
Explicitly Close() obj after ReadFull()
Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>
This commit is contained in:
1 parent
e1960cadb2
commit
edb1843f24
1 file changed
+11
-1
@@ -97,7 +97,17 @@ func (be s3) Load(h backend.Handle, p []byte, off int64) (int, error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
be.connChan <- struct{}{}
|
be.connChan <- struct{}{}
|
||||||
}()
|
}()
|
||||||
return io.ReadFull(obj, p)
|
|
||||||
|
// This may not read the whole object, so ensure object
|
||||||
|
// is closed to avoid duplicate connections.
|
||||||
|
n, err := io.ReadFull(obj, p)
|
||||||
|
if err != nil {
|
||||||
|
obj.Close()
|
||||||
|
} else {
|
||||||
|
err = obj.Close()
|
||||||
|
}
|
||||||
|
return n, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save stores data in the backend at the handle.
|
// Save stores data in the backend at the handle.
|
||||||
|
|||||||
Reference in new issue
Block a user