Skip to content

Commit

Permalink
Fix attributes for bucket creation (#1)
Browse files Browse the repository at this point in the history
Fix an issue when buckets are created as files, not as folders

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
  • Loading branch information
kvaps authored Sep 27, 2024
1 parent 7e42220 commit ca85ac2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/driver/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"os"
"strings"
"time"

"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
Expand Down Expand Up @@ -101,8 +103,14 @@ func (s *provisionerServer) createBucket(ctx context.Context, bucketName string)
Entry: &filer_pb.Entry{
Name: bucketName,
IsDirectory: true,
Attributes: &filer_pb.FuseAttributes{
FileMode: uint32(0777 | os.ModeDir),
Crtime: time.Now().Unix(),
Mtime: time.Now().Unix(),
},
},
}

_, err := s.filerClient.CreateEntry(ctx, req)
if err != nil {
return fmt.Errorf("failed to create bucket in filer: %w", err)
Expand All @@ -113,8 +121,11 @@ func (s *provisionerServer) createBucket(ctx context.Context, bucketName string)
// Delete a bucket in SeaweedFS using the Filer.
func (s *provisionerServer) deleteBucket(ctx context.Context, bucketId string) error {
req := &filer_pb.DeleteEntryRequest{
Directory: s.filerBucketsPath,
Name: bucketId,
Directory: s.filerBucketsPath,
Name: bucketId,
IsDeleteData: true,
IsRecursive: true,
IgnoreRecursiveError: true,
}
_, err := s.filerClient.DeleteEntry(ctx, req)
if err != nil {
Expand Down

0 comments on commit ca85ac2

Please sign in to comment.