Skip to content

Commit 620367f

Browse files
committed
优化文件搜索工具。
1 parent 7837a44 commit 620367f

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/services/littleTools/FileSearchToolService.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ public void addSearchIndexFile(Path path) {
167167
Iterator<Path> pathIterator = stream.iterator();
168168
while (pathIterator.hasNext()) {
169169
Path curPath = pathIterator.next();
170-
ThreadUtil.execute(() -> {
171-
try {
172-
addIndexDocument(curPath.toFile());
173-
if (Files.isDirectory(curPath)) {
174-
addSearchIndexFile(curPath);
175-
}
176-
} catch (Exception e) {
177-
log.warn("添加索引失败:", e);
170+
try {
171+
addIndexDocument(curPath.toFile());
172+
if (Files.isDirectory(curPath)) {
173+
addSearchIndexFile(curPath);
178174
}
179-
});
175+
} catch (Exception e) {
176+
log.warn("添加索引失败:", e);
177+
}
180178
}
179+
indexWriter.commit();
181180
} catch (Exception e) {
182181
log.warn("获取失败:", e);
183182
}
@@ -197,7 +196,7 @@ public void addIndexDocument(File file) throws Exception {
197196
doc.add(new StringField("isDirectory", String.valueOf(file.isDirectory()), Field.Store.NO));
198197
indexWriter.updateDocument(new Term("absolutePath", file.getAbsolutePath()), doc);
199198
// indexWriter.addDocument(doc);
200-
indexWriter.commit();
199+
// indexWriter.commit();
201200
}
202201

203202
public void autoRefreshIndexAction() {

0 commit comments

Comments
 (0)