Browse Source

REPORT-88094 fix: 文件数量较多时,listEntry结果不全

release/11.0
Afly 2 years ago
parent
commit
da7ee21d50
  1. 11
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

11
src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

@ -87,6 +87,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
collectFileEntry(result, objectListing);
while (objectListing.isTruncated()) {
objectListing = s3.listNextBatchOfObjects(objectListing);
collectFileEntry(result, objectListing);
}
return result.toArray(new FineFileEntry[0]);
}
private void collectFileEntry(List<FineFileEntry> result, ObjectListing objectListing) {
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
@ -98,8 +107,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
entry.setDirectory(true);
result.add(entry);
}
return result.toArray(new FineFileEntry[0]);
}
@Override

Loading…
Cancel
Save