mirror of
https://github.com/distribution/distribution.git
synced 2025-09-16 15:21:37 +00:00
Ignore self reference object on empty prefix
When a given prefix is empty and we attempt to list its content AWS returns that the prefix contains one object with key defined as the prefix with an extra "/" at the end. e.g. If we call ListObjects() passing to it an existing but empty prefix, say "my/empty/prefix", AWS will return that "my/empty/prefix/" is an object inside "my/empty/prefix" (ListObjectsOutput.Contents). This extra "/" causes the upload purging process to panic. On normal circunstances we never find empty prefixes on S3 but users may touch it. Signed-off-by: Ricardo Maraschini <rmarasch@redhat.com>
This commit is contained in:
@@ -986,6 +986,11 @@ func (d *driver) doWalk(parentCtx context.Context, objectCount *int64, path, pre
|
||||
}
|
||||
|
||||
for _, file := range objects.Contents {
|
||||
// empty prefixes are listed as objects inside its own prefix.
|
||||
// https://docs.aws.amazon.com/AmazonS3/latest/user-guide/using-folders.html
|
||||
if strings.HasSuffix(*file.Key, "/") {
|
||||
continue
|
||||
}
|
||||
walkInfos = append(walkInfos, walkInfoContainer{
|
||||
FileInfoFields: storagedriver.FileInfoFields{
|
||||
IsDir: false,
|
||||
|
Reference in New Issue
Block a user