Commit 9cec4744 authored by Klaus Wölfel's avatar Klaus Wölfel

Provide max_file_count option\n to define the maximum number of files to upload at once

parent d68feb18
......@@ -112,6 +112,10 @@ public class FilenameFileInputPlugin implements FileInputPlugin
@ConfigDefault("null")
Optional<Integer> getFileSize();
@Config("max_file_count")
@ConfigDefault("null")
Optional<Integer> getMaxFileCount();
@Config("follow_symlinks")
@ConfigDefault("false")
boolean getFollowSymlinks();
......@@ -120,6 +124,7 @@ public class FilenameFileInputPlugin implements FileInputPlugin
@ConfigDefault("false")
boolean getIgnoreLastFile();
List<String> getFiles();
void setFiles(List<String> files);
......@@ -137,7 +142,15 @@ public class FilenameFileInputPlugin implements FileInputPlugin
PluginTask task = config.loadConfig(PluginTask.class);
// list files recursively
List<String> files = listFiles(task);
List<String> files = new ArrayList<String>(listFiles(task));
Collections.sort(files);
// only process <= max_file_count number of files
final Integer maxFileCount = task.getMaxFileCount().orNull();
if (maxFileCount != null && files.size() > maxFileCount) {
files = files.subList(0, maxFileCount);
}
log.info("Loading files {}", files);
task.setFiles(files);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment