mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-18 18:32:30 +00:00
⚡ Download files in parallel
This commit is contained in:
parent
98738cb5a6
commit
aeda619104
@ -12,11 +12,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
s3Types "github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/client"
|
||||
@ -330,7 +332,11 @@ func downloadTarFromS3(s3Url string) (tarPath string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for _, object := range listObjectsOutput.Contents {
|
||||
wg.Add(1)
|
||||
go func(object s3Types.Object) {
|
||||
defer wg.Done()
|
||||
objectKey := *object.Key
|
||||
|
||||
fullPath := filepath.Join(tempDirPath, objectKey)
|
||||
@ -356,7 +362,9 @@ func downloadTarFromS3(s3Url string) (tarPath string, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(object)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
tarPath, err = tarDirectory(tempDirPath)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user