Commit 21b4a103 authored by Tatyana's avatar Tatyana 👽

List converted to Set

parent 24329ab0
......@@ -149,7 +149,7 @@ public class FxAdminController extends FxController {
fileSearcher = FileSearcher.getInstance();
Thread fileSearcherThread = new Thread(() -> {
List<File> files = fileSearcher.prepareFiles(root.toPath());
List<File> files = new ArrayList<>(fileSearcher.prepareFiles(root.toPath()));
List<File> peFiles;
if (isPE) {
......
......@@ -113,14 +113,15 @@ public class FileMonitor extends Thread {
Path name = ev.context();
Path child = dir.resolve(name);
fileSearcher.addFile(child.toAbsolutePath().toFile());
// print out event
logger.info(String.format("%s: %s\n", event.kind().name(), child));
if (event.kind() == ENTRY_CREATE)
if (event.kind() == ENTRY_CREATE && !child.toAbsolutePath().toFile().isDirectory()) {
fileSearcher.addFile(child.toAbsolutePath().toFile());
if (event.kind() == ENTRY_DELETE)
}
if (event.kind() == ENTRY_DELETE && !child.toAbsolutePath().toFile().isDirectory()) {
fileSearcher.removeFile(child.toAbsolutePath().toFile());
}
// if directory is created, and watching recursively, then
// register it and its sub-directories
......
......@@ -8,20 +8,22 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
public class FileSearcher {
private static FileSearcher instance;
private FileMonitor monitor;
private List<File> foundedFiles;
private Set<File> foundedFiles;
private AtomicInteger filesCounter = new AtomicInteger(0);
public List<File> prepareFiles(Path root) {
public Set<File> prepareFiles(Path root) {
filesCounter.set(0);
foundedFiles = new ArrayList<>();
foundedFiles = new HashSet<>();
try {
monitor = new FileMonitor(instance, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment