OpenUHS icon indicating copy to clipboard operation
OpenUHS copied to clipboard

Invalid folder name when opening UHS file

Open thinkedem opened this issue 2 years ago • 5 comments

When I try to open a downloaded UHS file from the hints/ subfolder, the app instead tries to open the file from a folder called hintss:

Problem: java.io.FileNotFoundException: ./hintss/indy4.uhs (No such file or directory)

Creating a symlink to the hints folder as hintss allows me to open the file correctly. OS: MacOS 12.3.1 Java: 1.8.0_152 OpenUHS: 0.6.6 (prebuilt binaries from sourceforge)

thinkedem avatar Apr 07 '22 08:04 thinkedem

I didn't see "hintss" anywhere in the code, nor anything that'd tack an extra 's' on. Can you give a more detailed step-by-step guide to recreate this problem?

I tried on Windows with OpenUHS 0.6.6...

  • In the Downloader tab, I clicked "Refresh", selected indy4, and clicked "Download".
  • Then I had no trouble double-clicking the Downloader tab's indy4 row to open it.
  • I also had no trouble clicking the Reader tab's "Open" button to choose the file itself.

Vhati avatar Apr 15 '22 05:04 Vhati

MacOS, OpenUHS 0.6.6

  • In the Downloader tab, I clicked Refresh, selected indy4, clicked Download.
  • I switched to the Reader tab, pressed open, selected indy4.uhs from the hints folder
  • I got an "OpenUHS Cannot Continue - Unreadable file or parsing error" popup.
  • When pressing OK on that alert, OpenUHS becomes unresponsive and cannot click on any buttons. The console output at this point is:
Warning: the font "Times" is not available, so "Lucida Bright" has been substituted, but may have unexpected appearance or behavor. Re-enable the "Times" font to remove this warning.
Info:    Fetching indy4.uhs...
Info:    Extracting INDY4.UHS...
Info:    Saved indy4.uhs
Info:    Opened indy4.uhs
Error:   No file
Problem: java.io.FileNotFoundException: ./hintss/indy4.uhs (No such file or directory)
           java.io.RandomAccessFile.open0(Native Method)
           java.io.RandomAccessFile.open(RandomAccessFile.java:316)
           java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
           java.io.RandomAccessFile.<init>(RandomAccessFile.java:124)
           org.openuhs.core.OpenUHSLib.parseFile(OpenUHSLib.java:200)
           org.openuhs.reader.UHSReaderPanel$7.run(UHSReaderPanel.java:296)

(Note the path in the problem containing an extra s) Additional tests:

  • Creating other folders ('test', 'files') and moving the uhs file there allows to open the file
  • Creating a folder called 'hintss', copying the uhs file to this folder and trying to open it from the original (hints) folder allows to open the file; but when trying to open it from the hintss folder, I get an error Problem: java.io.FileNotFoundException: ./hintsss/indy4.uhs (No such file or directory) (note the triple s this time)...

thinkedem avatar Apr 15 '22 06:04 thinkedem

Thank you. That's perfect! Now that I see the code, I'm shocked I never ran into that myself. Off-by-one stuff while string trimming.

This is the prodding I needed to revisit OpenUHS. Past me accumulated a LOT of (mostly invisible) improvements awaiting a new release. IIRC a couple new features weren't yet working, so I burned out. Gotta reacquaint myself with the code now...

Edit: This bug disappeared when the code was thoroughly rewritten.

Vhati avatar Apr 16 '22 17:04 Vhati

Edit: This bug disappeared when the code was thoroughly rewritten. Hi I'm not sure what you mean by that, cause I do still have the issue with the 0.6.6 release, but only with the hints folder. If I put the files into another folder (i.e. 'test' or 'files') it works just fine, but since the default folder is 'hints', that's a bit awkward to use - and the 'hints' folder still have the above issue. Or is the 0.6.6 not the latest version? In that case, could you upload the latest compiled binaries please?

thinkedem avatar Apr 25 '22 06:04 thinkedem

@Vhati Looks like you didn't commit your changes, FYI :)

agnesnutter avatar Mar 30 '23 15:03 agnesnutter