Commit 485546b1 authored by Rina Sergeeva's avatar Rina Sergeeva

File Monitor ::: archive add deleted

parent 5f0a5173
......@@ -26,7 +26,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class FxAdminController extends FxController {
......@@ -148,11 +147,8 @@ public class FxAdminController extends FxController {
fileSearcher = FileSearcher.getInstance();
Thread fileSearcherThread = new Thread(() -> {
<<<<<<< HEAD
Set<File> files = fileSearcher.prepareFiles(root.toPath());
=======
List<File> files = new ArrayList<>(fileSearcher.prepareFiles(root.toPath()));
>>>>>>> master
List<File> peFiles;
if (isPE) {
......
......@@ -3,6 +3,7 @@ package application.util;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
......@@ -113,14 +114,17 @@ public class FileMonitor extends Thread {
Path name = ev.context();
Path child = dir.resolve(name);
// print out event
logger.info(String.format("%s: %s\n", event.kind().name(), child));
if (event.kind() == ENTRY_CREATE && !child.toAbsolutePath().toFile().isDirectory()) {
fileSearcher.addFile(child.toAbsolutePath().toFile());
UnzipUtil unzipUtil = new UnzipUtil();
File childFile = child.toAbsolutePath().toFile();
if (event.kind() == ENTRY_CREATE && !childFile.isDirectory() && !unzipUtil.isZip(childFile)) {
fileSearcher.addFile(childFile);
}
if (event.kind() == ENTRY_DELETE && !child.toAbsolutePath().toFile().isDirectory()) {
fileSearcher.removeFile(child.toAbsolutePath().toFile());
if (event.kind() == ENTRY_DELETE && !childFile.isDirectory() && !unzipUtil.isZip(childFile)) {
fileSearcher.removeFile(childFile);
}
// if directory is created, and watching recursively, then
......
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