Bug 454965 - Stats plugin should use XDG_STATE_HOME rather than the hardcoded .skrooge path to store files
Summary: Stats plugin should use XDG_STATE_HOME rather than the hardcoded .skrooge pat...
Status: RESOLVED FIXED
Alias: None
Product: skrooge
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR task
Target Milestone: ---
Assignee: Stephane MANKOWSKI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-07 12:02 UTC by contact
Modified: 2023-03-11 21:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description contact 2022-06-07 12:02:10 UTC
The stats plugin will write a txt file summarising statistics to $HOME/.skrooge. This is hardcoded in plugins/generic/skg_statistic/skgstatisticplugin.cpp. Instead, this file should be written to $XDG_STATE_HOME (one could also argue $XDG_CACHE_HOME is appropriate). Of course when this environment variable isn't defined the path should cascade in the usual fashion.

Because this is hardcoded it effects all (unpatched) Linux distros.
Comment 1 Stephane MANKOWSKI 2023-02-08 15:08:21 UTC
Hi,

The path is not hardcoded. 
The path is computed by using qt api like this:
                QString appname = KAboutData::applicationData().componentName();
                QDir::home().mkdir("." % appname);
                QString docUUID = QString(QCryptographicHash::hash(m_currentDocument->getCurrentFileName().toLatin1(), QCryptographicHash::Md5).toHex());
                m_file = QDir::homePath() % "/." % appname % "/" % docUUID % ".stats.txt";

So, there is no issue for me.
Comment 2 contact 2023-02-26 05:52:59 UTC
Hi, yes, that is exactly what I mean. QDir::homePath() % "/." % appname % is equivalent to $HOME/skrooge. Rather CacheLocation should be used (see https://doc.qt.io/qt-5/qstandardpaths.html; $XDG_STATE_HOME doesn't seem to be added yet).
Comment 3 Stephane MANKOWSKI 2023-03-11 21:44:43 UTC
Git commit 2eabe937cfefe7c0bac06288470fd679d8917fec by Stephane MANKOWSKI.
Committed on 11/03/2023 at 21:44.
Pushed by smankowski into branch 'master'.

Stats plugin should use XDG_STATE_HOME rather than the hardcoded .skrooge path to store files

M  +1    -0    CHANGELOG
M  +5    -2    plugins/generic/skg_statistic/skgstatisticplugin.cpp

https://invent.kde.org/office/skrooge/commit/2eabe937cfefe7c0bac06288470fd679d8917fec