Refactor FastFile API
This commit is contained in:
parent
9fa587319f
commit
cfd862c057
|
@ -240,7 +240,7 @@ public class ScriptShellMethods {
|
|||
}
|
||||
|
||||
public static FastFile memoize(File self) {
|
||||
return new FastFile(self.getPath());
|
||||
return new FastFile(self);
|
||||
}
|
||||
|
||||
public static File moveTo(File self, File destination) throws IOException {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.filebot.media;
|
||||
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.regex.Pattern.*;
|
||||
|
@ -1402,21 +1401,6 @@ public class MediaDetection {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<File> getMediaUnits(File folder) {
|
||||
if (folder.isHidden()) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
if (folder.isDirectory() && !isDiskFolder(folder)) {
|
||||
List<File> children = new ArrayList<File>();
|
||||
for (File f : getChildren(folder)) {
|
||||
children.addAll(getMediaUnits(f));
|
||||
}
|
||||
}
|
||||
|
||||
return singletonList(folder);
|
||||
}
|
||||
|
||||
public static void warmupCachedResources() throws Exception {
|
||||
// load filter data
|
||||
MediaDetection.getClutterFileFilter();
|
||||
|
|
|
@ -69,7 +69,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
|
|||
}
|
||||
|
||||
// use fast file to minimize system calls like length(), isDirectory(), isFile(), ...
|
||||
FastFile root = FastFile.create(filter(files, FOLDERS))[0];
|
||||
FastFile root = new FastFile(filter(files, FOLDERS).get(0));
|
||||
|
||||
// publish on EDT
|
||||
TreeNode[] node = { getTreeNode(root) };
|
||||
|
|
|
@ -55,7 +55,8 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
|
|||
// load files recursively by default
|
||||
load(files, action != TransferAction.LINK, fileset);
|
||||
|
||||
publish(FastFile.create(fileset));
|
||||
// use fast file to minimize system calls like length(), isDirectory(), isFile(), ...
|
||||
publish(fileset.stream().map(FastFile::new).toArray(File[]::new));
|
||||
}
|
||||
|
||||
private void load(List<File> files, boolean recursive, Collection<File> sink) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.filebot.ui.rename;
|
|||
|
||||
import static java.awt.datatransfer.DataFlavor.*;
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.MediaTypes.*;
|
||||
import static net.filebot.hash.VerificationUtilities.*;
|
||||
import static net.filebot.ui.transfer.FileTransferable.*;
|
||||
|
@ -98,7 +97,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
|
|||
loadTorrentFiles(files, values);
|
||||
} else {
|
||||
// load all files from the given folders recursively up do a depth of 32
|
||||
addAll(values, FastFile.create(listFiles(files)));
|
||||
listFiles(files).stream().map(FastFile::new).forEach(values::add);
|
||||
}
|
||||
|
||||
model.addAll(values);
|
||||
|
|
|
@ -182,7 +182,7 @@ class ChecksumTableModel extends AbstractTableModel {
|
|||
cell.addPropertyChangeListener(progressListener);
|
||||
|
||||
if (!checksumColumns.contains(cell.getRoot())) {
|
||||
checksumColumns.add(new FastFile(cell.getRoot().getPath()));
|
||||
checksumColumns.add(new FastFile(cell.getRoot()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.filebot.util;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FastFile extends File {
|
||||
|
||||
|
@ -16,8 +15,8 @@ public class FastFile extends File {
|
|||
private File[] listFiles;
|
||||
private String canonicalPath;
|
||||
|
||||
public FastFile(String path) {
|
||||
super(path);
|
||||
public FastFile(File file) {
|
||||
super(file.getPath());
|
||||
}
|
||||
|
||||
public FastFile(File parent, String child) {
|
||||
|
@ -197,8 +196,4 @@ public class FastFile extends File {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static FastFile[] create(Collection<File> files) {
|
||||
return files.stream().map(f -> new FastFile(f.getPath())).toArray(FastFile[]::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue