Skip to content

Commit 845b9b9

Browse files
authored
feat!: BREAKING CHANGE - added max files limit (#685)
1 parent 3f4813c commit 845b9b9

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

src/main/java/io/kestra/plugin/aws/s3/Download.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ public class Download extends AbstractS3Object implements RunnableTask<Download.
113113
)
114114
protected Property<String> regexp;
115115

116+
@Builder.Default
116117
@Schema(
117118
title = "The maximum number of files to retrieve at once"
118119
)
119-
private Property<Integer> maxFiles;
120+
private Property<Integer> maxFiles = Property.ofValue(25);
120121

121122
@Schema(
122123
title = "The account ID of the expected bucket owner",

src/main/java/io/kestra/plugin/aws/s3/Downloads.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ public class Downloads extends AbstractS3Object implements RunnableTask<Download
9292
@Builder.Default
9393
protected final Property<Filter> filter = Property.ofValue(Filter.BOTH);
9494

95+
@Builder.Default
9596
@Schema(
9697
title = "The maximum number of files to retrieve at once"
9798
)
98-
private Property<Integer> maxFiles;
99+
private Property<Integer> maxFiles = Property.ofValue(25);
99100

100101
private Property<ActionInterface.Action> action;
101102

src/main/java/io/kestra/plugin/aws/s3/List.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ public class List extends AbstractS3Object implements RunnableTask<List.Output>,
6666

6767
protected Property<String> regexp;
6868

69+
@Builder.Default
6970
@Schema(
7071
title = "The maximum number of files to retrieve at once"
7172
)
72-
private Property<Integer> maxFiles;
73+
private Property<Integer> maxFiles = Property.ofValue(25);
7374

7475
@Builder.Default
7576
protected final Property<Filter> filter = Property.ofValue(Filter.BOTH);
@@ -89,8 +90,8 @@ public Output run(RunContext runContext) throws Exception {
8990
runContext.render(prefix).as(String.class).orElse(null)
9091
);
9192

92-
Integer rMaxFiles = runContext.render(this.maxFiles).as(Integer.class).orElse(null);
93-
if (rMaxFiles != null && list.size() > rMaxFiles) {
93+
int rMaxFiles = runContext.render(this.maxFiles).as(Integer.class).orElse(25);
94+
if (list.size() > rMaxFiles) {
9495
runContext.logger().warn(
9596
"Listing returned {} files but maxFiles limit is {}. Only the first {} files will be returned. " +
9697
"Increase the maxFiles property if you need more files.",

src/main/java/io/kestra/plugin/aws/s3/Trigger.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ public class Trigger extends AbstractTrigger implements PollingTriggerInterface,
166166
@Builder.Default
167167
private final Property<On> on = Property.ofValue(On.CREATE_OR_UPDATE);
168168

169+
@Builder.Default
169170
@Schema(
170171
title = "The maximum number of files to retrieve at once"
171172
)
172-
private Property<Integer> maxFiles;
173+
private Property<Integer> maxFiles = Property.ofValue(25);
173174

174175
private Property<String> stateKey;
175176

src/test/java/io/kestra/plugin/aws/s3/ListTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@ void maxFilesNotExceeded() throws Exception {
106106
}
107107

108108
@Test
109-
void maxFilesNotSpecified() throws Exception {
109+
void maxFilesDefault() throws Exception {
110110
this.createBucket();
111111

112112
String dir = IdUtils.create();
113113

114-
// Upload 30 files
114+
// Upload 30 files (more than default limit of 25)
115115
for (int i = 0; i < 30; i++) {
116116
upload("/tasks/s3/" + dir);
117117
}
118118

119-
// List WITHOUT specifying maxFiles - should return all files (no default limit)
119+
// List WITHOUT specifying maxFiles - should use default of 25 and return first 25 files
120120
List task = list()
121121
.prefix(Property.ofValue("/tasks/s3/" + dir))
122122
.build();
123123
List.Output run = task.run(runContext(task));
124124

125-
assertThat(run.getObjects().size(), is(30));
125+
assertThat(run.getObjects().size(), is(25));
126126
}
127127
}

0 commit comments

Comments
 (0)