Azure backend: limit http concurrency in Stat(), Test(), Remove()
as per discussion in PR #1399
This commit is contained in:
parent
d01d07fc0a
commit
981752ade0
1 changed files with 17 additions and 2 deletions
|
@ -227,13 +227,17 @@ func (be *Backend) Load(ctx context.Context, h restic.Handle, length int, offset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stat returns information about a blob.
|
// Stat returns information about a blob.
|
||||||
func (be *Backend) Stat(ctx context.Context, h restic.Handle) (bi restic.FileInfo, err error) {
|
func (be *Backend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error) {
|
||||||
debug.Log("%v", h)
|
debug.Log("%v", h)
|
||||||
|
|
||||||
objName := be.Filename(h)
|
objName := be.Filename(h)
|
||||||
blob := be.container.GetBlobReference(objName)
|
blob := be.container.GetBlobReference(objName)
|
||||||
|
|
||||||
if err := blob.GetProperties(nil); err != nil {
|
be.sem.GetToken()
|
||||||
|
err := blob.GetProperties(nil)
|
||||||
|
be.sem.ReleaseToken()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
debug.Log("blob.GetProperties err %v", err)
|
debug.Log("blob.GetProperties err %v", err)
|
||||||
return restic.FileInfo{}, errors.Wrap(err, "blob.GetProperties")
|
return restic.FileInfo{}, errors.Wrap(err, "blob.GetProperties")
|
||||||
}
|
}
|
||||||
|
@ -244,7 +248,11 @@ func (be *Backend) Stat(ctx context.Context, h restic.Handle) (bi restic.FileInf
|
||||||
// Test returns true if a blob of the given type and name exists in the backend.
|
// Test returns true if a blob of the given type and name exists in the backend.
|
||||||
func (be *Backend) Test(ctx context.Context, h restic.Handle) (bool, error) {
|
func (be *Backend) Test(ctx context.Context, h restic.Handle) (bool, error) {
|
||||||
objName := be.Filename(h)
|
objName := be.Filename(h)
|
||||||
|
|
||||||
|
be.sem.GetToken()
|
||||||
found, err := be.container.GetBlobReference(objName).Exists()
|
found, err := be.container.GetBlobReference(objName).Exists()
|
||||||
|
be.sem.ReleaseToken()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -254,7 +262,11 @@ func (be *Backend) Test(ctx context.Context, h restic.Handle) (bool, error) {
|
||||||
// Remove removes the blob with the given name and type.
|
// Remove removes the blob with the given name and type.
|
||||||
func (be *Backend) Remove(ctx context.Context, h restic.Handle) error {
|
func (be *Backend) Remove(ctx context.Context, h restic.Handle) error {
|
||||||
objName := be.Filename(h)
|
objName := be.Filename(h)
|
||||||
|
|
||||||
|
be.sem.GetToken()
|
||||||
_, err := be.container.GetBlobReference(objName).DeleteIfExists(nil)
|
_, err := be.container.GetBlobReference(objName).DeleteIfExists(nil)
|
||||||
|
be.sem.ReleaseToken()
|
||||||
|
|
||||||
debug.Log("Remove(%v) at %v -> err %v", h, objName, err)
|
debug.Log("Remove(%v) at %v -> err %v", h, objName, err)
|
||||||
return errors.Wrap(err, "client.RemoveObject")
|
return errors.Wrap(err, "client.RemoveObject")
|
||||||
}
|
}
|
||||||
|
@ -282,7 +294,10 @@ func (be *Backend) List(ctx context.Context, t restic.FileType) <-chan string {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
be.sem.GetToken()
|
||||||
obj, err := be.container.ListBlobs(params)
|
obj, err := be.container.ListBlobs(params)
|
||||||
|
be.sem.ReleaseToken()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue