|
|
@ -339,6 +339,11 @@ func (s3a *S3ApiServer) hasObjectsWithActiveLocks(bucket string) (bool, error) { |
|
|
return hasLocks, nil |
|
|
return hasLocks, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
// lockCheckPaginationSize is the page size for listing directories during lock checks
|
|
|
|
|
|
lockCheckPaginationSize = 10000 |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// errStopPagination is a sentinel error to signal early termination of pagination
|
|
|
// errStopPagination is a sentinel error to signal early termination of pagination
|
|
|
var errStopPagination = errors.New("stop pagination") |
|
|
var errStopPagination = errors.New("stop pagination") |
|
|
|
|
|
|
|
|
@ -347,7 +352,7 @@ var errStopPagination = errors.New("stop pagination") |
|
|
func (s3a *S3ApiServer) paginateEntries(dir string, fn func(entries []*filer_pb.Entry) error) error { |
|
|
func (s3a *S3ApiServer) paginateEntries(dir string, fn func(entries []*filer_pb.Entry) error) error { |
|
|
startFrom := "" |
|
|
startFrom := "" |
|
|
for { |
|
|
for { |
|
|
entries, isLast, err := s3a.list(dir, "", startFrom, false, 10000) |
|
|
|
|
|
|
|
|
entries, isLast, err := s3a.list(dir, "", startFrom, false, lockCheckPaginationSize) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
// Fail-safe: propagate error to prevent incorrect bucket deletion
|
|
|
// Fail-safe: propagate error to prevent incorrect bucket deletion
|
|
|
return fmt.Errorf("failed to list directory %s: %w", dir, err) |
|
|
return fmt.Errorf("failed to list directory %s: %w", dir, err) |
|
|
@ -427,6 +432,10 @@ func (s3a *S3ApiServer) recursivelyCheckLocks(dir string, relativePath string, h |
|
|
if err := s3a.recursivelyCheckLocks(subDir, subRelativePath, hasLocks, currentTime); err != nil { |
|
|
if err := s3a.recursivelyCheckLocks(subDir, subRelativePath, hasLocks, currentTime); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
// Early exit if a locked object was found in the subdirectory
|
|
|
|
|
|
if *hasLocks { |
|
|
|
|
|
return errStopPagination |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
|
|