2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

s3: Make sure to return connection token

This commit is contained in:
Alexander Neumann 2017-02-10 20:49:37 +01:00
parent 64165ea4c8
commit 7a0303f7ae

View File

@ -155,11 +155,16 @@ func (be *s3) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, er
objName := be.s3path(h)
// get token for connection
<-be.connChan
obj, err := be.client.GetObject(be.bucketname, objName)
if err != nil {
debug.Log(" err %v", err)
// return token
be.connChan <- struct{}{}
return nil, errors.Wrap(err, "client.GetObject")
}
@ -170,12 +175,18 @@ func (be *s3) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, er
_, err = obj.Seek(offset, 0)
if err != nil {
_ = obj.Close()
// return token
be.connChan <- struct{}{}
return nil, errors.Wrap(err, "obj.Seek")
}
rd := wrapReader{
ReadCloser: obj,
f: func() {
debug.Log("Close()")
// return token
be.connChan <- struct{}{}
},
}
@ -183,6 +194,7 @@ func (be *s3) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, er
}
defer func() {
// return token
be.connChan <- struct{}{}
}()