Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3tables: normalize filer errors and use standard helpers

Chris Lub4d8350936db
diff --git a/weed/s3api/s3tables/filer_ops.go b/weed/s3api/s3tables/filer_ops.go
index 645500af4e..8ccfdb004a 100644
--- a/weed/s3api/s3tables/filer_ops.go
+++ b/weed/s3api/s3tables/filer_ops.go
@@ -10,7 +10,6 @@ import (
)
var (
- ErrNotFound = errors.New("entry not found")
ErrAttributeNotFound = errors.New("attribute not found")
)
@@ -40,7 +39,7 @@ func (h *S3TablesHandler) setExtendedAttribute(ctx context.Context, client filer
dir, name := splitPath(path)
// First, get the existing entry
- resp, err := client.LookupDirectoryEntry(ctx, &filer_pb.LookupDirectoryEntryRequest{
+ resp, err := filer_pb.LookupEntry(ctx, client, &filer_pb.LookupDirectoryEntryRequest{
Directory: dir,
Name: name,
})
@@ -49,9 +48,6 @@ func (h *S3TablesHandler) setExtendedAttribute(ctx context.Context, client filer
}
entry := resp.Entry
- if entry == nil {
- return fmt.Errorf("%w: %s", ErrNotFound, path)
- }
// Update the extended attributes
if entry.Extended == nil {
@@ -70,7 +66,7 @@ func (h *S3TablesHandler) setExtendedAttribute(ctx context.Context, client filer
// getExtendedAttribute gets an extended attribute from an entry
func (h *S3TablesHandler) getExtendedAttribute(ctx context.Context, client filer_pb.SeaweedFilerClient, path, key string) ([]byte, error) {
dir, name := splitPath(path)
- resp, err := client.LookupDirectoryEntry(ctx, &filer_pb.LookupDirectoryEntryRequest{
+ resp, err := filer_pb.LookupEntry(ctx, client, &filer_pb.LookupDirectoryEntryRequest{
Directory: dir,
Name: name,
})
@@ -78,10 +74,6 @@ func (h *S3TablesHandler) getExtendedAttribute(ctx context.Context, client filer
return nil, err
}
- if resp.Entry == nil {
- return nil, fmt.Errorf("%w: %s", ErrNotFound, path)
- }
-
if resp.Entry.Extended == nil {
return nil, fmt.Errorf("%w: %s", ErrAttributeNotFound, key)
}
@@ -99,7 +91,7 @@ func (h *S3TablesHandler) deleteExtendedAttribute(ctx context.Context, client fi
dir, name := splitPath(path)
// Get the existing entry
- resp, err := client.LookupDirectoryEntry(ctx, &filer_pb.LookupDirectoryEntryRequest{
+ resp, err := filer_pb.LookupEntry(ctx, client, &filer_pb.LookupDirectoryEntryRequest{
Directory: dir,
Name: name,
})
@@ -108,9 +100,6 @@ func (h *S3TablesHandler) deleteExtendedAttribute(ctx context.Context, client fi
}
entry := resp.Entry
- if entry == nil {
- return fmt.Errorf("%w: %s", ErrNotFound, path)
- }
// Remove the extended attribute
if entry.Extended != nil {
@@ -141,9 +130,9 @@ func (h *S3TablesHandler) deleteDirectory(ctx context.Context, client filer_pb.S
// entryExists checks if an entry exists at the given path
func (h *S3TablesHandler) entryExists(ctx context.Context, client filer_pb.SeaweedFilerClient, path string) bool {
dir, name := splitPath(path)
- resp, err := client.LookupDirectoryEntry(ctx, &filer_pb.LookupDirectoryEntryRequest{
+ _, err := filer_pb.LookupEntry(ctx, client, &filer_pb.LookupDirectoryEntryRequest{
Directory: dir,
Name: name,
})
- return err == nil && resp.Entry != nil
+ return err == nil
}