mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 15:32:40 -04:00
scan of library only at startup
This commit is contained in:
parent
d1b5eccc51
commit
da3f2311e5
@ -67,7 +67,6 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
private final LibraryNode root;
|
||||
private ShapeFactory shapeFactory;
|
||||
private ElementLibraryFolder custom;
|
||||
private ElementLibraryFolder library;
|
||||
private File rootLibraryPath;
|
||||
|
||||
/**
|
||||
@ -161,7 +160,10 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
populateNodeMap();
|
||||
|
||||
custom = new ElementLibraryFolder(root, Lang.get("menu_custom"));
|
||||
library = new ElementLibraryFolder(root, Lang.get("menu_library"));
|
||||
|
||||
File libPath = Settings.getInstance().get(Keys.SETTINGS_LIBRARY_PATH);
|
||||
if (libPath != null && libPath.exists())
|
||||
new ElementLibraryFolder(root, Lang.get("menu_library")).scanFolder(libPath);
|
||||
|
||||
isProgrammable.clear();
|
||||
root.traverse(libraryNode -> {
|
||||
@ -296,22 +298,12 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
|
||||
private void rescanFolder() throws IOException {
|
||||
LOGGER.debug("rescan folder");
|
||||
File libPath = Settings.getInstance().get(Keys.SETTINGS_LIBRARY_PATH);
|
||||
if (libPath != null && !libPath.exists()) libPath = null;
|
||||
|
||||
LibraryNode cn1 = library.scanFolder(libPath);
|
||||
LibraryNode cn2 = custom.scanFolder(rootLibraryPath);
|
||||
LibraryNode cn = custom.scanFolder(rootLibraryPath);
|
||||
|
||||
populateNodeMap();
|
||||
|
||||
if (cn1 == root || cn2 == root) {
|
||||
fireLibraryChanged(root);
|
||||
} else {
|
||||
if (cn1 != null)
|
||||
fireLibraryChanged(cn1);
|
||||
if (cn2 != null)
|
||||
fireLibraryChanged(cn2);
|
||||
}
|
||||
if (cn != null)
|
||||
fireLibraryChanged(cn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,15 +37,6 @@ public class ElementLibraryFolder {
|
||||
return node;
|
||||
}
|
||||
|
||||
private boolean hasChanged(File path) {
|
||||
File lp = lastPath;
|
||||
lastPath = path;
|
||||
|
||||
if (lp == path) return false;
|
||||
|
||||
return lp == null || !lp.equals(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* scans the given folder
|
||||
*
|
||||
@ -54,7 +45,6 @@ public class ElementLibraryFolder {
|
||||
*/
|
||||
public LibraryNode scanFolder(File path) {
|
||||
LibraryNode changedNode = null;
|
||||
if (hasChanged(path)) {
|
||||
if (path != null) {
|
||||
if (node == null) {
|
||||
node = new LibraryNode(menuTitle);
|
||||
@ -71,7 +61,6 @@ public class ElementLibraryFolder {
|
||||
node = null;
|
||||
changedNode = root;
|
||||
}
|
||||
}
|
||||
return changedNode;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user