-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use standard configuration directories #6005
base: master
Are you sure you want to change the base?
Conversation
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Windows
🤖{"platform_name_to_artifacts": {"Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/mm958rwvy1wcr6k2/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/42909767"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/ki7xr0ieb48bsn0w/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/42909767"}]}, "commit_sha": "7413c8c4fce8a9b16e2174b50d118ad52efcd0ac"} |
It works ok with windows (64) as well. My user folder is in D: (not as usual in C:) and it works ok.
|
@superpaik |
This would be great to see happen! Putting configuration files in the right places seems more professional. I don't know about those additional commits though, does that really belong in the same PR? |
@MRAAGH |
what happens if files in both locations exist? I haven't checked, but imo LMMS should either give a notice or parse the newest config. |
Usually you would have a predefined order in which candidate configuration files are checked. When a configuration file is found, no additional paths are checked. So, if both locations exist, one overrides the other. Don't rely on modification time with config files, that's just asking for weird accidents |
The legacy location (the user's home directory) is checked first and used if the |
Wouldn't it be better to prefer the new location, and only use the old one as a fallback? |
Is there a reason for all the manual inlining? It makes the diff a lot harder to follow and I can't tell if it's necessary somehow. |
@Spekular No specific reason for the manual inlining. Should methods like |
At a glance I'd say it seemed easier to tell what was being done. I would keep them, but since it's a matter of taste I think the second reviewer can decide (serving as tiebreaker). |
b49e64d restores the directory init methods in case the maintainers prefer this way. |
I think |
src/core/ConfigManager.cpp
Outdated
// Determine RC file location to use if not in development | ||
if (!m_isDevelopment) | ||
{ | ||
QString cfgDir = QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation).at(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of issues here:
standardLocations
isn't guaranteed to return any locations at all, so this may index the result out of bounds.- We use the same directory both to read and to write the config file. The paths in
standardLocations
aren't guaranteed to be writable: they may include system-wide config locations, for example. - In the case of XDG directories, relative paths are considered invalid. However, Qt makes no effort to omit these paths from the result.
I think the easiest way to address these is to use the writable location for configuration files instead. (It's possible for the writable location to be an empty string, or a relative path, in which case I'd just fall back to the legacy location.)
If you want to support reading configuration files from all possible locations, you could consider copying any such file found to the writable location first. You could also include the legacy location as one of these possible locations, which would offer a migration mechanism instead of a fallback mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should we just fall back to the legacy path if standardLocations
returns an empty or unwritable path?
Are there any updates with this?
I think it would be a safer bet to use platform agnostic means to determine the configuration folder. Less code maintenance for you guys and better compatibility with non standard OSes, environments and distros. There must be a library out there that handles this for you already. |
Drafted because this is no longer being worked on. |
With this PR, the "lmmsrc.xml" file is stored in the platform's standard directory for configuration files, but the file at the legacy location is checked first for backwards compatibility.
According to the documentation at https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum, the location is
~/.config/<APPNAME>
for Linux,C:/Users/<USER>/AppData/Local/<APPNAME>
for Windows, and~/Library/Preferences/<APPNAME>
for macOS.Closes #5869.
Note: tested only on Linux.
Without eb37ee6, the directory is created even when LMMS runs in development mode, which is not desired, as "lmmsrc.xml" is stored on the same directory LMMS runs from in this case.
Some method names in
ConfigManager
have problems:initDevelopmentWorkingDir()
never touchesm_workingDir
, whileinitPortableWorkingDir()
andinitInstalledWorkingDir()
set the RC file in addition tom_workingDir
. It looks likeConfigManager
needs some reorganization (which 38d67b2 does).