mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-26 09:49:28 +00:00
Merge a28e25c63f into 12eabbd76d
This commit is contained in:
commit
5e3bb91cb1
1 changed files with 11 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
|
||||||
|
|
@ -61,7 +62,9 @@ func AzureBlobstoreUpload(path string, name string, config AzureBlobstoreConfig)
|
||||||
}
|
}
|
||||||
defer in.Close()
|
defer in.Close()
|
||||||
|
|
||||||
_, err = client.UploadFile(context.Background(), config.Container, name, in, nil)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
_, err = client.UploadFile(ctx, config.Container, name, in, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,8 +83,10 @@ func AzureBlobstoreList(config AzureBlobstoreConfig) ([]*container.BlobItem, err
|
||||||
pager := client.NewListBlobsFlatPager(config.Container, nil)
|
pager := client.NewListBlobsFlatPager(config.Container, nil)
|
||||||
|
|
||||||
var blobs []*container.BlobItem
|
var blobs []*container.BlobItem
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
|
defer cancel()
|
||||||
for pager.More() {
|
for pager.More() {
|
||||||
page, err := pager.NextPage(context.TODO())
|
page, err := pager.NextPage(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -111,9 +116,12 @@ func AzureBlobstoreDelete(config AzureBlobstoreConfig, blobs []*container.BlobIt
|
||||||
}
|
}
|
||||||
// Iterate over the blobs and delete them
|
// Iterate over the blobs and delete them
|
||||||
for _, blob := range blobs {
|
for _, blob := range blobs {
|
||||||
if _, err := client.DeleteBlob(context.Background(), config.Container, *blob.Name, nil); err != nil {
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
|
if _, err := client.DeleteBlob(ctx, config.Container, *blob.Name, nil); err != nil {
|
||||||
|
cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
cancel()
|
||||||
fmt.Printf("deleted %s (%s)\n", *blob.Name, blob.Properties.LastModified)
|
fmt.Printf("deleted %s (%s)\n", *blob.Name, blob.Properties.LastModified)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue