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"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
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/feature/s3/manager"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"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"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -330,7 +332,11 @@ func downloadTarFromS3(s3Url string) (tarPath string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
for _, object := range listObjectsOutput.Contents {
|
for _, object := range listObjectsOutput.Contents {
|
||||||
|
wg.Add(1)
|
||||||
|
go func(object s3Types.Object) {
|
||||||
|
defer wg.Done()
|
||||||
objectKey := *object.Key
|
objectKey := *object.Key
|
||||||
|
|
||||||
fullPath := filepath.Join(tempDirPath, objectKey)
|
fullPath := filepath.Join(tempDirPath, objectKey)
|
||||||
@ -356,7 +362,9 @@ func downloadTarFromS3(s3Url string) (tarPath string, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}(object)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
tarPath, err = tarDirectory(tempDirPath)
|
tarPath, err = tarDirectory(tempDirPath)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user