Skip to content

Commit

Permalink
Move isMatch to FileWatcher to prevent file locks. (qzind#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf authored Feb 13, 2020
1 parent 1a3e93f commit 506093c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/qz/communication/FileIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public FileIO(Session session, JSONObject params, Path originalPath, Path absolu
}
}

private boolean isMatch(String fileName) {
public boolean isMatch(String fileName) {
boolean match = inclusions.isEmpty();
for (String inclusion : inclusions) {
if(FilenameUtils.wildcardMatch(fileName, inclusion, caseSensitivity)) {
Expand Down Expand Up @@ -134,8 +134,6 @@ public void setWk(WatchKey wk) {
}

public void fileChanged(String fileName, String type, String fileData) {
if (!isMatch(fileName)) return;

StreamEvent evt = new StreamEvent(StreamEvent.Stream.FILE, StreamEvent.Type.ACTION)
.withData("file", getOriginalPath().resolve(fileName))
.withData("eventType", type);
Expand Down
2 changes: 2 additions & 0 deletions src/qz/utils/FileWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static void deregisterWatch(FileIO fileIO) {
private synchronized static void fileChanged(Path path, String fileName, String type) {
Path filePath = path.resolve(fileName);
for(FileIO fio : fileIOs) {
if (!fio.isMatch(fileName)) continue;

String fileData = null;
if (fio.getAbsolutePath().equals(path.normalize().toAbsolutePath())) {
if (!type.equals("ENTRY_DELETE") && fio.returnsContents() && !Files.isDirectory(filePath)) {
Expand Down

0 comments on commit 506093c

Please sign in to comment.