count files added to the library

This commit is contained in:
hneemann 2017-05-16 19:52:10 +02:00
parent 7d949367eb
commit 5812890831

View File

@ -282,7 +282,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
changedNode = customNode; changedNode = customNode;
} }
scanFolder(rootLibraryPath, customNode); int num = scanFolder(rootLibraryPath, customNode);
LOGGER.debug("found " + num + " files");
} else if (customNode != null) { } else if (customNode != null) {
root.remove(customNode); root.remove(customNode);
customNode = null; customNode = null;
@ -305,7 +306,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
l.libraryChanged(node); l.libraryChanged(node);
} }
private void scanFolder(File path, LibraryNode node) { private int scanFolder(File path, LibraryNode node) {
int num = 0;
File[] list = path.listFiles(); File[] list = path.listFiles();
if (list != null) { if (list != null) {
ArrayList<File> orderedList = new ArrayList<>(Arrays.asList(list)); ArrayList<File> orderedList = new ArrayList<>(Arrays.asList(list));
@ -313,17 +315,20 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
for (File f : orderedList) { for (File f : orderedList) {
if (f.isDirectory()) { if (f.isDirectory()) {
LibraryNode n = new LibraryNode(f.getName()); LibraryNode n = new LibraryNode(f.getName());
scanFolder(f, n); num += scanFolder(f, n);
if (!n.isEmpty()) if (!n.isEmpty())
node.add(n); node.add(n);
} }
} }
for (File f : orderedList) { for (File f : orderedList) {
final String name = f.getName(); final String name = f.getName();
if (f.isFile() && name.endsWith(".dig")) if (f.isFile() && name.endsWith(".dig")) {
node.add(new LibraryNode(f)); node.add(new LibraryNode(f));
num++;
}
} }
} }
return num;
} }
/** /**