-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FileMonitor for LaTeX citations #10585
Comments
Hi! Hope you're all doing well! |
Sure, go ahead :-) |
Thank you very much! :) |
Hello, how are you? I hope all is well! I'd like to sincerely apologize for the delay in addressing the issue. I encountered some unexpected setbacks, but I'm back and aim to resolve it as soon as possible. Thank you in advance for your assistance and understanding! :) |
If you manage to do it without causing extensive performance degradation for large libraries, then not having a refresh button would be fair enough :-) |
Hey, my university software engineering group are willing to tackle this issue. Would it be possible to assign us ? Here are our git username @rachedkko @VinterSallad @Emiesce @MercuriaL01 and @roxannecvl. |
Sure, I will assign you. |
Hi, i am also working on this issue ! |
Hi, I am in the same group and university course! |
Hello! I am working on it too together with @rachedkko @VinterSallad @Emiesce and @roxannecvl |
For organisational purposes it is totally fine, if only one person is assigned, if we know you are a group and work together. It is only possible to assign somebody who has commented in the issue, but if everybody comments, it will be a lot of spam, if we have like 160 developers. |
As a general advice for newcomers: check out Contributing for a start. Also, guidelines for setting up a local workspace is worth having a look at. Feel free to ask here at GitHub, if you have any issue related questions. If you have questions about how to setup your workspace use JabRef's Gitter chat. Try to open a (draft) pull-request early on, so that people can see you are working on the issue and so that they can see the direction the pull request is heading towards. This way, you will likely receive valuable feedback. |
…to LatexCitation (JabRef#10585) Known Issues: Sometimes throws ConcurrentModificationException from DefaultFileUpdateMonitor whenever a change occurs in the tracked directory Does not have any kind of shutdown Is not able to track changes in nested directories Does not handle whenever a directory is changed from the initial one properly Makes use of a Deprecated Class
…Ref#10585) Changed the MultiMap into a synchronized type for safety Used the Platform.runLater() to ensure processes are executed on correct threads Not sure what the side effects of these fixes are
Made sure that filemonitor first is added when the user navigates to LaTeX Citation for the first time for each .bib tab, also added logic to remove the old listener whenever the directory target is changed However, an issue is that listener seemingly is still watching over the old directory even though the listener has been removed
Hi, I wanted to ask about the requirement of having a proper shutdown to the listeners at the end. When are the listeners supposed to be shut down exactly? If it is on program shutdown, then I think it is all handled since the fileMonitor I get is from the Globals class. Or is it whenever the user navigates out of the Latex Citations tab? |
I would like to work on this issue. |
@koppor, while working on this issue, implementing a new directory monitor there are a few options to use: java.nio.file.WatchServiceTested on Windows 11 using There are multiple issues:
io.methvin.watcher.DirectoryWatcherTested on Windows 11 using mentioned example in the repo. It resolves issues (1, 3, 4) that occur in org.apache.commons.io.monitorThere are no issues with it, but it uses a polling mechanism at fixed intervals to check for any new events. This can waste CPU cycles, especially if no change occurs. However, it can handle huge files without overflowing. What do you suggest I should do? I haven't tested on any other device or OS to see if these issues are reproducible or not. |
@LoayGhreeb Nice evaluation! I need to think in ADRs, especially MADR. What are our decision drivers?
Seeing your JDK links, I checked the source of both the Apache Commons IO and methvin's watchers. I saw at https://github.com/gmethvin/directory-watcher/blob/3218d68a845ebd803ebd98af3be4692d1b63e12c/core/src/main/java/io/methvin/watcher/DirectoryWatcher.java#L162 that in non-macOS. Re-iterating on your comment again ( I also checked FileAlterationObserver.java. I liked Apache Commons does a check on modification time and length (refresh). This is IMHO the better approach Thus, Apache Commons is IMHO the better way to go. BTW: Being able to press the dot (.) to open a VS Code in the Web for a GitHub repo is very nice for code browsing. In case you didn't know. |
Our bib file watcher is based on the java watch service |
It works because it doesn't care about the sub-directories |
We could register the .tex files directly. Watch the latex directory. And then check for \input and \include. However, this has more efforts than using Apache Commons FileMonitor and filtering for .tex files. |
Does this handle the creation or deletion of .tex files in sub-directories of the latex directory? By the way, can the \include command include a .tex file that is in another directory? If yes, should I also watch that directory to monitor changes to that file (Maybe using the |
What I meant is that Apache Commons FileMonitor and filtering for .tex files is great (because the manual way has more efforts). Just go ahead with that. Seems to be more clean code!
Yes. One could even have macro expansion on the file name. Rarely used though.
When using Apache Commons FileMonitor , that quesion is obsolete, isn't it? |
Great! Will implement it and submit a pull request soon.
Still need to know how to handle the case where a .tex file in the watched directory includes another .tex file outside the watched directory. Maybe it's better not to think about those cases for now. Implementing the basics first will make it easier to determine what should be done later. |
PhD thesis are typically split among several files. Thus, watching a directory and all sub directories for .tex files should cover almost all cases. If it is too difficult to watch a directory for .tex file creation, then we can rely on the "Refresh" button though. |
The LaTeX citations are NOT backed by a file update monitor.
Rewrite the code to use our
org.jabref.gui.util.DefaultFileUpdateMonitor
(or a new file update monitor) with proper shutdown at the end.(Note: This is the technically sound fix for #10584)
Update
A first PR was submitted at #10937. It turned out, that a new FileMonitor is needed. It should watch a directory.
The file listeners:
org.jabref.gui.entryeditor.LatexCitationsTabViewModel
: Move awayorg.jabref.gui.entryeditor.LatexCitationsTabViewModel#searchDirectory
,org.jabref.gui.entryeditor.LatexCitationsTabViewModel#searchAndParse
as classCitationFinder
in packageorg.jabref.logic.texparser
. -- Also test cases need to be addedorg.jabref.model.texparser.LatexParserResult
to allow partial updates. That means: If file X is changed, call new DefaultLatexParser().parse(X) and change the contents oforg.jabref.model.texparser.LatexParserResult#citations
accordingly. IMHO, a map fromPath
toSet<Citations>
(Multimap) should be kept. The value before the update and after the update be stored. A diff calculated. That diff should be applied tocitations
. - The methodupdate
can be implemented inLatexParserResult
. - The classLatexParserResult
should be renamed inCitationState
.CitationState#update(path)
can be called. That method should simply add the file to the currently known files. -- Deletion has to be handled separately. event: delete, new methodCitationState#remove(path)
calledReasons: Energy saving. Very little CPU usage for an update on one file. Although your current method works, it parses ALL
.tex
files again, and handles the content. Large LaTeX projects have dozens oftex
files, which are very long. This costs time.The text was updated successfully, but these errors were encountered: