albar965 / littlenavmap

Little Navmap is a free flight planner, navigation tool, moving map, airport search and airport information system for Flight Simulator X, Microsoft Flight Simulator 2020, Prepar3D and X-Plane.
https://albar965.github.io/littlenavmap.html
GNU General Public License v3.0
1.23k stars 161 forks source link

[3.0.3.rc] Web server document root change isn't updated in registry #1093

Closed bkielczewski closed 4 months ago

bkielczewski commented 4 months ago
  1. Have webserver's document root set to something initially
  2. The path will be in HKEY_CURRENT_USER\Software\ABarthel\Little Navmap
  3. Now change the document root to something else
  4. The path in HKEY_CURRENT_USER\Software\ABarthel\Little Navmap won't get updated

The result of this is that webserver will still try to locate files by the old path from the registry, with document root in app pointing to somewhere else.

For clean installs, it probably never changes from default path.

This bug is likely present since 3.0.2.beta.

Screenshot 2024-02-22 214055

albar965 commented 4 months ago

LNM does not save any settings the registry. All are stored in the configuration file C:\Users\YOURUSERNAME\AppData\Roaming\ABarthel\little_navmap.ini. Look for section [OptionsDialog] and key Widget_lineEditOptionsWebDocroot there.

bkielczewski commented 4 months ago

If so, why does this entry exist in the registry and gets recreated when deleted and LNM is restarted after that? Why do StaticFileController log entries use the path from registry rather than from little_navmap.ini?

Widget_lineEditOptionsWebDocroot=C:\\Users\\bkiel\\IdeaProjects\\bartk-ingamepanels-lnm\\dist\\bkiel-ingamepanels-lnm\\web points to what is displayed in the dialog, that's ok. The behavior of the web server is weird.

albar965 commented 4 months ago

Ok. I see. This quite annoying and should not happen. Not my code but I'll fix this.

albar965 commented 4 months ago

Correction. It is my code but the stupid QSettings object writes to the registry even if not synced. :man_facepalming:

bkielczewski commented 4 months ago

Thank you for checking and quick reaction. With this one I'm mostly worried about webserver behavior, so when I ask my users to set the document root to something it will actually serve static files from there.

albar965 commented 4 months ago

The registry is more (ab)used as a temporary store in this case. The change of the root folder does still work. That's what at least a quick test on Linux shows here.

Will fix and I can also send you a pre-3.0.4 stable before releasing for quick tests.

bkielczewski commented 4 months ago

So on windows, it works partially.

Repro:

  1. path in the tool window = E:/MSFS/Packages/Community/bkiel-ingamepanels-lnm/web//index.html
  2. update registry: reg add "HKEY_CURRENT_USER\Software\ABarthel\Little Navmap" /v "path" /t REG_SZ /d "C:\wrong"
  3. restart LNM, make a request to http://localhost:8965 in the browser
  4. in the browser white page and a bunch of 404 on static resources
  5. in the log:

    TemplateCache: trying file E:/MSFS/Packages/Community/bkiel-ingamepanels-lnm/web//index.html StaticFileController: Open file C:/wrong/runtime.03a33c114cec2ee3.js

So when changing document root: it updates in the tool window, in little_navmap.ini, and it is even loading index.html from correct location. But if this index.html references any static resources (images, js) they are fetched from C:\wrong, where they don't exist, resulting in 404s.

I'm happy to help with testing.

albar965 commented 4 months ago

Try this 3.0.3.rc2: https://k00.fr/52wh20b7

bkielczewski commented 4 months ago

Thanks.

  1. Document root folder change works good, static content loads
  2. No registry key anymore
  3. I appreciate the error message on wrong doc root, it's clearer

I'll keep using this version throughout the weekend, so far looks perfect. Thank you for fixing!

albar965 commented 4 months ago

Thanks for the confirmation. :+1: