Streamify -mediainfo and -list commands to make them more responsive when used on the command-line on large datasets

This commit is contained in:
Reinhard Pointner 2017-02-23 20:49:51 +08:00
parent 9e13e1928e
commit f95689b5a1
4 changed files with 6 additions and 11 deletions

View File

@ -220,8 +220,8 @@ public class ArgumentBean {
return filter == null ? null : new ExpressionFilter(filter);
}
public FileFilter getExpressionFileFilter() throws Exception {
return filter == null ? null : new ExpressionFileFilter(filter);
public FileFilter getFileFilter() throws Exception {
return filter == null ? FILES : new ExpressionFileFilter(filter);
}
public Datasource getDatasource() {

View File

@ -60,12 +60,12 @@ public class ArgumentProcessor {
// print media info
if (args.mediaInfo) {
return print(cli.getMediaInfo(args.getFiles(true), args.getExpressionFileFilter(), args.getExpressionFormat()));
return print(cli.getMediaInfo(args.getFiles(true), args.getFileFilter(), args.getExpressionFormat()));
}
// revert files
if (args.revert) {
return cli.revert(args.getFiles(false), args.getExpressionFileFilter(), args.getRenameAction()).isEmpty() ? 1 : 0;
return cli.revert(args.getFiles(false), args.getFileFilter(), args.getRenameAction()).isEmpty() ? 1 : 0;
}
// file operations

View File

@ -1030,11 +1030,6 @@ public class CmdlineOperations implements CmdlineInterface {
@Override
public Stream<String> getMediaInfo(Collection<File> files, FileFilter filter, ExpressionFormat format) throws Exception {
// use default file filter
if (filter == null) {
return getMediaInfo(files, FILES, format);
}
// use default expression format if not set
if (format == null) {
return getMediaInfo(files, filter, new ExpressionFormat("{fn} [{resolution} {vc} {channels} {ac} {minutes}m]"));
@ -1062,7 +1057,7 @@ public class CmdlineOperations implements CmdlineInterface {
return history.entrySet().stream().filter(it -> {
File original = it.getKey();
File current = it.getValue();
return Stream.of(current, original).flatMap(f -> listPath(f).stream()).anyMatch(whitelist::contains) && current.exists() && (filter == null || filter.accept(current));
return Stream.of(current, original).flatMap(f -> listPath(f).stream()).anyMatch(whitelist::contains) && current.exists() && filter.accept(current);
}).map(it -> {
File original = it.getKey();
File current = it.getValue();

View File

@ -437,7 +437,7 @@ public abstract class ScriptShellBaseClass extends Script {
ArgumentBean args = getArgumentBean(parameters);
try {
return getCLI().getMediaInfo(files, args.getExpressionFileFilter(), args.getExpressionFormat());
return getCLI().getMediaInfo(files, args.getFileFilter(), args.getExpressionFormat());
} catch (Exception e) {
printException(e);
}