jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Importing an entry with the browser extension doesn't delete temporary files

Open ror3d opened this issue 1 year ago • 31 comments

JabRef version

5.12 (latest release)

Operating system

Windows

Details on version and operating system

Windows 11

Checked with the latest development build (copy version output from About dialog)

  • [X] I made a backup of my libraries before testing the latest development version.
  • [X] I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

  1. Edit the JabRefHost.ps1 file in your JabRef installation
  2. Change line 40 (Remove-Item...) with the following:
     $rout = Remove-Item $tempfile *>&1
     $wshell = New-Object -ComObject Wscript.Shell
     $wshell.Popup("ROut: $rout", 0, "JabRef", 0x0 + 0x30)
    
  3. Open JabRef
  4. Use the JabRef browser extension in any article to try to import it
  5. Upon import, a popup window will open showing the output of the Remove-Item command, reporting that it cannot remove the temporary file because it is being used: image

This is probably due to the JabRef command being called unblocking. The script has to exit to send back the result to the browser, but the open JabRef instance might still have the file open, so the script can't delete it before exiting.

Being able to send the file as stdin, or as a command-line argument, instead of creating a temporary file, could be a solution for this issue. Another approach could be connection using sockets in some way.

Appendix

No response

ror3d avatar Mar 19 '24 13:03 ror3d

This is related to https://github.com/JabRef/JabRef-Browser-Extension/issues/493 but that one is about the issue of the extension reporting an error, which should be solved with PR #11047, whereas this issue is about the still unresolved problem left in that PR.

ror3d avatar Mar 19 '24 13:03 ror3d

Being able to send the file as stdin, or as a command-line argument, instead of creating a temporary file, could be a solution for this issue.

This is what we had before. But some of the bibtex can be quite long and then you hit the maximum length of the command line argument.

Is it really important to you to delete the temporary file? Windows 10+ normally clean the temp folder automatically, so it shouldn't really be a problem that there are still files lying around. I honestly don't see a clean way to clean them up, since as you say we need to return as fast as possible from the script.

It would perhaps work to pass a --deleteWhenClosing cmd line arg to jabref's main exe, and then clean up the file when the main jabref program is closed - but that feels a bit overkill.

tobiasdiez avatar Mar 19 '24 13:03 tobiasdiez

Right, as command-line argument would have such problem, sending them through stdin should work well though.

On the other hand, I am also thinking of ways that https://github.com/JabRef/JabRef-Browser-Extension/issues/481 could use a similar approach, but that might be a bit more tricky.

As for temp files being automatically deleted, if that is the case then this is not really a problem I guess.

ror3d avatar Mar 19 '24 14:03 ror3d