From 6595bc2c05ccaf91af56b905eb76118b5484e547 Mon Sep 17 00:00:00 2001 From: Josh Montoya Date: Mon, 12 Aug 2024 13:11:09 -0700 Subject: [PATCH] use semaphore --- s3.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s3.go b/s3.go index 5b1dba8..5b00a5b 100644 --- a/s3.go +++ b/s3.go @@ -53,6 +53,7 @@ type S3 struct { } func (s *S3) Export(ctx context.Context, prefix, filename string, r io.Reader) (newFilename string, err error) { + s.sema.Use() rs, ok := r.(io.ReadSeeker) if !ok { rs = aws.ReadSeekCloser(r) @@ -76,6 +77,7 @@ func (s *S3) Export(ctx context.Context, prefix, filename string, r io.Reader) ( } func (s *S3) Import(ctx context.Context, prefix, filename string, w io.Writer) (err error) { + s.sema.Use() filepath := path.Join(prefix, filename) getInput := s3.GetObjectInput{ Bucket: aws.String(s.o.Bucket), @@ -93,6 +95,7 @@ func (s *S3) Import(ctx context.Context, prefix, filename string, w io.Writer) ( } func (s *S3) Get(ctx context.Context, prefix, filename string, fn func(r io.Reader) error) (err error) { + s.sema.Use() var out *s3.GetObjectOutput filepath := path.Join(prefix, filename) input := newGetInputObject(s.o.Bucket, filepath) @@ -105,6 +108,7 @@ func (s *S3) Get(ctx context.Context, prefix, filename string, fn func(r io.Read } func (s *S3) GetNext(ctx context.Context, prefix, lastFilename string) (nextKey string, err error) { + s.sema.Use() startAfter := path.Join(prefix, lastFilename) input := s3.ListObjectsV2Input{ Bucket: aws.String(s.o.Bucket),