Skip to content

Commit 93ad499

Browse files
Fixes the auto-update problem with TexGroups on Ubuntu Linux and makes the detection of file modifications more reliable (#7412)
* two possible fixes for the auto-update problem with TexGroups on Linux * revert changes * fix for opening library and parsing an existing TexGroup or changing a group to a TexGroup * making the detection of file modifications more reliable by detecting file creation events for existing files as well as file modifications * changelog
1 parent 00894a3 commit 93ad499

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
4747
- We fixed an issue where the file path is invisible in dark theme. [#7382](https://github.com/JabRef/jabref/issues/7382)
4848
- We fixed an issue where the secondary sorting is not working for some special fields. [#7015](https://github.com/JabRef/jabref/issues/7015)
4949
- We fixed an issue where changing the font size makes the font size field too small. [#7085](https://github.com/JabRef/jabref/issues/7085)
50+
- We fixed an issue with TexGroups on Linux systems, where the modification of an aux-file did not trigger an auto-update for TexGroups. Furthermore, the detection of file modifications is now more reliable. [#7412](https://github.com/JabRef/jabref/pull/7412)
5051
- We fixed an issue where the Unicode to Latex formatter produced wrong results for characters with a codepoint higher than Character.MAX_VALUE. [#7387](https://github.com/JabRef/jabref/issues/7387)
5152

5253
### Removed

src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void run() {
5656
if (kind == StandardWatchEventKinds.OVERFLOW) {
5757
Thread.yield();
5858
continue;
59-
} else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
60-
// We only handle "ENTRY_MODIFY" here, so the context is always a Path
59+
} else if (kind == StandardWatchEventKinds.ENTRY_CREATE || kind == StandardWatchEventKinds.ENTRY_MODIFY) {
60+
// We only handle "ENTRY_CREATE" and "ENTRY_MODIFY" here, so the context is always a Path
6161
@SuppressWarnings("unchecked")
6262
WatchEvent<Path> ev = (WatchEvent<Path>) event;
6363
Path path = ((Path) key.watchable()).resolve(ev.context());
@@ -88,7 +88,7 @@ public void addListenerForFile(Path file, FileUpdateListener listener) throws IO
8888
if (isActive()) {
8989
// We can't watch files directly, so monitor their parent directory for updates
9090
Path directory = file.toAbsolutePath().getParent();
91-
directory.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
91+
directory.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
9292
listeners.put(file, listener);
9393
}
9494
}

src/main/java/org/jabref/model/groups/TexGroup.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ public class TexGroup extends AbstractGroup implements FileUpdateListener {
4747

4848
public static TexGroup create(String name, GroupHierarchyType context, Path filePath, AuxParser auxParser, FileUpdateMonitor fileMonitor, MetaData metaData) throws IOException {
4949
TexGroup group = new TexGroup(name, context, filePath, auxParser, fileMonitor, metaData);
50-
fileMonitor.addListenerForFile(filePath, group);
50+
fileMonitor.addListenerForFile(group.getFilePathResolved(), group);
5151
return group;
5252
}
5353

5454
public static TexGroup createWithoutFileMonitoring(String name, GroupHierarchyType context, Path filePath, AuxParser auxParser, FileUpdateMonitor fileMonitor, MetaData metaData) throws IOException {
5555
return new TexGroup(name, context, filePath, auxParser, fileMonitor, metaData);
5656
}
5757

58+
public Path getFilePathResolved() {
59+
return this.filePath;
60+
}
61+
5862
@Override
5963
public boolean contains(BibEntry entry) {
6064
if (keysUsedInAux == null) {

0 commit comments

Comments
 (0)