Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET_ALL_PAGES_IN_DIR doesn't work for "dirs" full of "subdirs" #73

Open
hartzell opened this issue Apr 4, 2023 · 0 comments
Open

GET_ALL_PAGES_IN_DIR doesn't work for "dirs" full of "subdirs" #73

hartzell opened this issue Apr 4, 2023 · 0 comments

Comments

@hartzell
Copy link

hartzell commented Apr 4, 2023

The fix in #31 doesn't seem to work if you attempt to list a directory (prefix) full of only subdirectories (longer prefixes) as page.Contents is 0 and it stops after the first page.

Various AWS SDK documentation and examples (e.g. here on GitHub just pass in a function that always returns true, apparently the SDK will stop calling it after the last page.

A better fix is something like this:

--- a/internal/service/amazon-s3.go
+++ b/internal/service/amazon-s3.go
@@ -37,7 +37,7 @@ func (c client) S3listObjects(bucket, prefix string) (*s3.ListObjectsOutput, err
                func(page *s3.ListObjectsOutput, lastPage bool) bool {
                        result.CommonPrefixes = append(result.CommonPrefixes, page.CommonPrefixes...)
                        result.Contents = append(result.Contents, page.Contents...)
-                       return len(page.Contents) == 1000
+                       return true
                })
        return result, err
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant