Skip to content

Commit

Permalink
don't check if bucket exists if autoBucket == false
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Sep 21, 2023
1 parent af47084 commit 1103de2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions gofakes3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,18 +1067,22 @@ func (g *GoFakeS3) putBucketVersioning(bucket string, w http.ResponseWriter, r *
}

func (g *GoFakeS3) ensureBucketExists(bucket string) error {
if !g.autoBucket {
return nil // nothing to do
}

exists, err := g.storage.BucketExists(bucket)
if err != nil {
return err
} else if exists {
return nil
}
if !exists && g.autoBucket {
if err := g.storage.CreateBucket(bucket); err != nil {
g.log.Print(LogErr, "autobucket create failed:", err)
return ResourceError(ErrNoSuchBucket, bucket)
}
} else if !exists {

if err := g.storage.CreateBucket(bucket); err != nil {
g.log.Print(LogErr, "autobucket create failed:", err)
return ResourceError(ErrNoSuchBucket, bucket)
}

return nil
}

Expand Down

0 comments on commit 1103de2

Please sign in to comment.