Skip to content

Commit d68fbfb

Browse files
committed
fixup! move file ops to FileSettingsService
1 parent 3850598 commit d68fbfb

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.io.IOException;
1919
import java.io.InputStream;
2020
import java.nio.file.ClosedWatchServiceException;
21-
import java.nio.file.Files;
2221
import java.nio.file.NoSuchFileException;
2322
import java.nio.file.Path;
2423
import java.nio.file.StandardWatchEventKinds;
@@ -243,7 +242,7 @@ protected final void watcherThread() {
243242
.collect(Collectors.toSet());
244243
for (var changedPath : changedPaths) {
245244
// If a symlinked dir changed in the settings dir, it could be linked to other symlinks, so reprocess all files
246-
if (Files.isDirectory(changedPath) && Files.isSymbolicLink(changedPath)) {
245+
if (filesIsDirectory(changedPath) && filesIsSymbolicLink(changedPath)) {
247246
reprocessAllChangedFilesInSettingsDir();
248247
break;
249248
} else if (fileChanged(changedPath)) {
@@ -385,6 +384,8 @@ private record FileUpdateState(long timestamp, String path, Object fileKey) {}
385384

386385
protected abstract boolean filesIsDirectory(Path path);
387386

387+
protected abstract boolean filesIsSymbolicLink(Path path);
388+
388389
protected abstract <A extends BasicFileAttributes> A filesReadAttributes(Path path, Class<A> clazz) throws IOException;
389390

390391
protected abstract Stream<Path> filesList(Path dir) throws IOException;

server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ protected boolean filesIsDirectory(Path path) {
467467
return Files.isDirectory(path);
468468
}
469469

470+
@Override
471+
protected boolean filesIsSymbolicLink(Path path) {
472+
return Files.isSymbolicLink(path);
473+
}
474+
470475
@Override
471476
protected <A extends BasicFileAttributes> A filesReadAttributes(Path path, Class<A> clazz) throws IOException {
472477
return Files.readAttributes(path, clazz);

server/src/test/java/org/elasticsearch/common/file/AbstractFileWatchingServiceTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ protected boolean filesIsDirectory(Path path) {
9898
return Files.isDirectory(path);
9999
}
100100

101+
@Override
102+
protected boolean filesIsSymbolicLink(Path path) {
103+
return Files.isSymbolicLink(path);
104+
}
105+
101106
@Override
102107
protected <A extends BasicFileAttributes> A filesReadAttributes(Path path, Class<A> clazz) throws IOException {
103108
return Files.readAttributes(path, clazz);

server/src/test/java/org/elasticsearch/common/file/MasterNodeFileWatchingServiceTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ protected boolean filesIsDirectory(Path path) {
8080
return Files.isDirectory(path);
8181
}
8282

83+
@Override
84+
protected boolean filesIsSymbolicLink(Path path) {
85+
return Files.isSymbolicLink(path);
86+
}
87+
8388
@Override
8489
protected <A extends BasicFileAttributes> A filesReadAttributes(Path path, Class<A> clazz) throws IOException {
8590
return Files.readAttributes(path, clazz);

0 commit comments

Comments
 (0)