Bug 382358 - Under Windows KDE Application configuration files must be stored in %APPDATA% not in %LOCALAPPDATA%
Summary: Under Windows KDE Application configuration files must be stored in %APPDATA%...
Status: REPORTED
Alias: None
Product: frameworks-kxmlgui
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks: 382363
  Show dependency treegraph
 
Reported: 2017-07-15 04:12 UTC by Thomas Debesse
Modified: 2022-05-25 08:12 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Debesse 2017-07-15 04:12:21 UTC
Hi, I discovered that on Windows platform, Digikam is storing it's `digikamrc` configuration in %LOCALAPPDATA%, which is wrong.

%LOCALAPPDATA% is a place that is tied to the local computer and can be safely thrown away, it's the right place for cache things (like `digikam/cache`, but not for config file.

For example, while connecting to a random workstation belonging to a Windows Domain %LOCALAPPDATA% would be something like "C:\Users\<username>\AppData\Local" but %APPDATA% would be something like "\\<server>\<username>\AppData".
On this configuration, the backup system only have to backup %APPDATA%.

On a Windows Domain setup, %APPDATA% is either available by roaming or by network drive, meaning any user can connect to any computer and recover it's own config file if this configfile is stored in %APPDATA%. It also means a computer can break and the user lost nothing. The sysadmin just put throw away the faulty computer and put a brand new one without having to copy files from the faulty computer.

On the contrary, if the config file is mistakenly stored in %LOCALAPPDATA% instead of %APPDATA%, everytime an user switch its computer (because it was replaced, or because computers are not tied to one user and everyone can use every computer), this user will have to reconfigure Digikam from scratch, and of course, the user will end with as many different configurations as computer he logged in. This also means that if the drive is lost, the digikam configuration is lost.

%LOCALAPPDATA% is not meant to be on backup, it's for local cache and stuff like that. %LOCALAPPDATA% is meant to store stuff that can change when user change its computer, which is not an user expects from a configuration file.

So, stuff like `digikamrc` and `digkam_tagmanagerrc` must be stored in %APPDATA%.

Stuff like `digikam\template.xml` (author templates) must be stored in %APPDATA%. By the way, it would be better to store author templates in database  like labels are, but that's another topic. As long as this kind of stuff is not stored is database, it must be stored in %APPDATA%.

Stuff like `digikam/cache` must remain in %LOCALAPPDATA%, that's the right place for that, because Domains administrator does not want to uselessly increase their backup size by storing per computer throwable temporary cache, and it would uselessly consume network and drive resources, breaking the purpose of a “local” cache.
Comment 1 Thomas Debesse 2017-07-15 07:05:24 UTC
See #382363 for the special case of `digikam\template.xml`.
Comment 2 Thomas Debesse 2017-07-15 07:08:47 UTC
linking bug 382363
Comment 3 Thomas Debesse 2017-07-20 14:52:15 UTC
Note that I noticed `showfoto` and `kdenlive` on windows are affected too. Do I have to open a bug for each software affected by this bug? This is probably a bug in a common component.
Comment 4 caulier.gilles 2018-01-14 02:07:42 UTC
It's a bug in common component from KDE library : KF5::KXMLGUI our KConfig, i'm not 100% sure. I forward to KDE core team for analyze.

Gilles Caulier
Comment 5 Thomas Debesse 2018-01-16 01:05:22 UTC
I confirm that bug also affects Krita, it's obiously a bug in a common component!
Comment 6 Thomas Debesse 2018-01-16 01:31:55 UTC
A quick lookup reveals many stuff in the whole kde tree uses `QStandardPaths::DataLocation` (which returns `%LocalAppData%` as `QStandardPaths::AppLocalDataLocation` does) or even `QStandardPaths::GenericDataLocation` that does exactly the same (and some code also uses %LocalAppData% directly) instead of `QStandardPaths::DataLocation` that returns %AppData% (added in Qt 5.4) which is the only viable option.

As read there:
https://doc-snapshots.qt.io/qt5-dev/qstandardpaths.html

> QStandardPaths::DataLocation
> Returns the same value as AppLocalDataLocation. This enumeration value is deprecated. Using AppDataLocation is preferable since on Windows, the roaming path is recommended.

> QStandardPaths::AppDataLocation
> Returns a directory location where persistent application data can be stored. This is an application-specific directory. To obtain a path to store data to be shared with other applications, use QStandardPaths::GenericDataLocation. The returned path is never empty. On the Windows operating system, this returns the roaming path. This enum value was added in Qt 5.4.

I would said that on Windows using `AppDataLocation` is not only recommended but required since other options (DataLocation, GenericDataLocation, AppLocalDataLocation) return a directory designed to be local to a disposable computer and to not be part of the user's profile. This directory is made to be not be shared among multiple computers, to not be backed up and to be wiped out. It's a bit like writing user's configuration in /temp: it's definitely not a place to save user's configuration.
Comment 7 Maik Qualmann 2018-12-19 17:50:33 UTC
*** Bug 402346 has been marked as a duplicate of this bug. ***
Comment 8 Thomas Debesse 2018-12-19 23:17:17 UTC
Bug 402346 is not a duplicate of this. Bug 402346 is saying that digikamrc must be stored withing a digikam/ directoy whatever the parent directory is, this issue is saying the parent directory is wrong.
Comment 9 Thomas Debesse 2018-12-19 23:27:04 UTC
Perhaps Qt documentation has to be edited to say:

> Beware: `QStandardPaths::DataLocation` is not doing what you think it is

QStandardPaths::DataLocation never returns the DataLocation, it returns a Local Cache Location.

The real DataLocation is given by QStandardPaths::AppDataLocation.

For storing disposable local (to the machine) cache, software can use QStandardPaths::AppLocalDataLocation. QStandardPaths::DataLocation seems to be  there just because of history, it mistakenly calls to QStandardPaths::AppLocalDataLocation which is wrong and is not what developer expects.