Browse Source

handle listing errors

pull/7426/head
chrislu 4 weeks ago
parent
commit
636540aba2
  1. 9
      weed/s3api/filer_util.go

9
weed/s3api/filer_util.go

@ -3,10 +3,11 @@ package s3api
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"math" "math"
"strings" "strings"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util"
@ -114,7 +115,7 @@ func (s3a *S3ApiServer) updateEntriesTTL(parentDirectoryPath string, ttlSec int3
var updateErrors []error var updateErrors []error
err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
ctx := context.Background() ctx := context.Background()
_ = filer_pb.SeaweedList(ctx, client, parentDirectoryPath, "", func(entry *filer_pb.Entry, isLast bool) error {
if listErr := filer_pb.SeaweedList(ctx, client, parentDirectoryPath, "", func(entry *filer_pb.Entry, isLast bool) error {
if entry.IsDirectory { if entry.IsDirectory {
if err := s3a.updateEntriesTTL(fmt.Sprintf("%s/%s", strings.TrimRight(parentDirectoryPath, "/"), entry.Name), ttlSec); err != nil { if err := s3a.updateEntriesTTL(fmt.Sprintf("%s/%s", strings.TrimRight(parentDirectoryPath, "/"), entry.Name), ttlSec); err != nil {
updateErrors = append(updateErrors, fmt.Errorf("dir %s: %w", entry.Name, err)) updateErrors = append(updateErrors, fmt.Errorf("dir %s: %w", entry.Name, err))
@ -139,7 +140,9 @@ func (s3a *S3ApiServer) updateEntriesTTL(parentDirectoryPath string, ttlSec int3
updateErrors = append(updateErrors, fmt.Errorf("file %s: %w", entry.Name, err)) updateErrors = append(updateErrors, fmt.Errorf("file %s: %w", entry.Name, err))
} }
return nil return nil
}, "", false, math.MaxInt32)
}, "", false, math.MaxInt32); listErr != nil {
return fmt.Errorf("list entries in %s: %w", parentDirectoryPath, listErr)
}
if len(updateErrors) > 0 { if len(updateErrors) > 0 {
return fmt.Errorf("failed to update %d entries: %v", len(updateErrors), updateErrors[0]) return fmt.Errorf("failed to update %d entries: %v", len(updateErrors), updateErrors[0])
} }

Loading…
Cancel
Save