Skip to content

Commit

Permalink
Merge pull request openshift#45 from flavianmissi/OCPBUGS-39108
Browse files Browse the repository at this point in the history
OCPBUGS-39108: avoid appending directory as file path in s3 driver Walk
  • Loading branch information
openshift-merge-bot[bot] authored Oct 23, 2024
2 parents 2799294 + 46744fd commit 9b9c54d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions registry/storage/driver/s3-aws/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,16 @@ func (d *driver) doWalk(parentCtx context.Context, objectCount *int64, path, pre
}
}

// in some cases the _uploads dir might be empty. when this happens, it would
// be appended twice to the walkInfos slice, once as [...]/_uploads and
// once more erroneously as [...]/_uploads/. the easiest way to avoid this is
// to skip appending filePath to walkInfos if it ends in "/". the loop through
// dirs will already have handled it in that case, so it's safe to continue this
// loop.
if strings.HasSuffix(filePath, "/") {
continue
}

walkInfos = append(walkInfos, storagedriver.FileInfoInternal{
FileInfoFields: storagedriver.FileInfoFields{
IsDir: false,
Expand Down Expand Up @@ -1427,8 +1437,6 @@ func (w *writer) Size() int64 {
return w.size
}

// Close flushes any remaining data in the buffer and releases the buffer back
// to the pool.
func (w *writer) Close() error {
if w.closed {
return fmt.Errorf("already closed")
Expand Down

0 comments on commit 9b9c54d

Please sign in to comment.