Skip to content

Commit

Permalink
Fixes the auto-update problem with TexGroups on Ubuntu Linux and make…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
systemoperator authored Feb 5, 2021
1 parent 00894a3 commit 93ad499
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the file path is invisible in dark theme. [#7382](https://github.com/JabRef/jabref/issues/7382)
- We fixed an issue where the secondary sorting is not working for some special fields. [#7015](https://github.com/JabRef/jabref/issues/7015)
- We fixed an issue where changing the font size makes the font size field too small. [#7085](https://github.com/JabRef/jabref/issues/7085)
- 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)
- 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)

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void run() {
if (kind == StandardWatchEventKinds.OVERFLOW) {
Thread.yield();
continue;
} else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
// We only handle "ENTRY_MODIFY" here, so the context is always a Path
} else if (kind == StandardWatchEventKinds.ENTRY_CREATE || kind == StandardWatchEventKinds.ENTRY_MODIFY) {
// We only handle "ENTRY_CREATE" and "ENTRY_MODIFY" here, so the context is always a Path
@SuppressWarnings("unchecked")
WatchEvent<Path> ev = (WatchEvent<Path>) event;
Path path = ((Path) key.watchable()).resolve(ev.context());
Expand Down Expand Up @@ -88,7 +88,7 @@ public void addListenerForFile(Path file, FileUpdateListener listener) throws IO
if (isActive()) {
// We can't watch files directly, so monitor their parent directory for updates
Path directory = file.toAbsolutePath().getParent();
directory.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
directory.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
listeners.put(file, listener);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/model/groups/TexGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ public class TexGroup extends AbstractGroup implements FileUpdateListener {

public static TexGroup create(String name, GroupHierarchyType context, Path filePath, AuxParser auxParser, FileUpdateMonitor fileMonitor, MetaData metaData) throws IOException {
TexGroup group = new TexGroup(name, context, filePath, auxParser, fileMonitor, metaData);
fileMonitor.addListenerForFile(filePath, group);
fileMonitor.addListenerForFile(group.getFilePathResolved(), group);
return group;
}

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

public Path getFilePathResolved() {
return this.filePath;
}

@Override
public boolean contains(BibEntry entry) {
if (keysUsedInAux == null) {
Expand Down

0 comments on commit 93ad499

Please sign in to comment.