Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion hatchery/sharedworkspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"io"
"net/http"
"path"
"strings"

Expand Down Expand Up @@ -73,7 +74,21 @@ func ensureKeepFiles(prefixes []SharedWorkspacePrefix) error {
for _, p := range prefixes {
key := path.Join(p.Prefix, ".keep")

_, err := svc.PutObject(&s3.PutObjectInput{
_, err := svc.HeadObject(&s3.HeadObjectInput{
Bucket: aws.String(p.BucketName),
Key: aws.String(key),
})
if err == nil {
// The .keep object already exists.
continue
}

// Only create the object when it does not exist.
if reqErr, ok := err.(awserr.RequestFailure); !ok || reqErr.StatusCode() != http.StatusNotFound {
return err
}

_, err = svc.PutObject(&s3.PutObjectInput{
Bucket: aws.String(p.BucketName),
Key: aws.String(key),
Body: nil,
Expand Down
Loading