sum size of all files

This commit is contained in:
Reinhard Pointner 2017-03-27 01:55:56 +08:00
parent 7663977c9a
commit 20c85970e2
2 changed files with 8 additions and 6 deletions

View File

@ -967,7 +967,13 @@ public class MediaBindingBean {
}
@Define("bytes")
public Long getFileSize() {
public long getFileSize() {
// sum size of all files
if (getMediaFile().isDirectory()) {
return listFiles(getMediaFile(), FILES).stream().mapToLong(File::length).sum();
}
// size of inferred media file (e.g. video file size for subtitle file)
return getInferredMediaFile().length();
}

View File

@ -20,7 +20,7 @@ public class VideoQuality implements Comparator<File> {
return DESCENDING_ORDER.compare(f1, f2) < 0;
}
private final Comparator<File> chain = comparing(f -> new MediaBindingBean(f, f), comparingInt(this::getRepack).thenComparingInt(this::getResolution).thenComparingLong(this::getSize));
private final Comparator<File> chain = comparing(f -> new MediaBindingBean(f, f), comparingInt(this::getRepack).thenComparingInt(this::getResolution).thenComparingLong(MediaBindingBean::getFileSize));
@Override
public int compare(File f1, File f2) {
@ -48,8 +48,4 @@ public class VideoQuality implements Comparator<File> {
return 0;
}
private long getSize(MediaBindingBean m) {
return m.getInferredMediaFile().length();
}
}