nextcloud / desktop

💻 Desktop sync client for Nextcloud
https://nextcloud.com/install/#install-clients
GNU General Public License v2.0
3.05k stars 801 forks source link

Logs are saved in XDG_CONFIG_HOME rather than XDG_STATE_HOME #3406

Open Toorero opened 3 years ago

Toorero commented 3 years ago

Expected behaviour

Logs should be saved (as stated by freedesktop) in the XDG_STATE_HOME. A log is clearly not a "user-specific configuration" and logs are explicitly featured as an example of data that should be stored in XDG_STATE_HOME

Actual behaviour

Logs are stored in the XDG_CONFIG_HOME instead in the Nextcloud folder instead.

Steps to reproduce

Just use the client and let it produce logs.

Client configuration

Client version: 3.2.2git

Operating system: Archlinux

OS language: German

Qt version used by client package (Linux only, see also Settings dialog): 5.15.2+kde+r196-1

Client package (From Nextcloud or distro) (Linux only): 3.2.2-1

Installation path of client: /usr/share/nextcloud

franga2000 commented 3 years ago

I'd like to take a crack at implementing this when I get the time, so here's a few preemptive questions for the maintainers:

  1. Should this also be done for Windows? (logging moved to QStandardPaths::AppLocalDataLocation == ~\AppData\Local\ instead of Roaming)
  2. Since there isn't a QStandardPaths entry for XDG_STATE_HOME (the spec is quite new) and most environments don't "implement" it yet (neither the variable nor the dir itself exist), would it make more sense to use the AppLocalDataLocation (~/.local/share/) on Linux as well?
  3. Changing defaultLogDir should be sufficient, right?
mgallien commented 3 years ago

Thanks for your proposition of help Sorry for the long time with no reply

I'd like to take a crack at implementing this when I get the time, so here's a few preemptive questions for the maintainers:

1. Should this also be done for Windows? (logging moved to `QStandardPaths::AppLocalDataLocation` == `~\AppData\Local\` instead of `Roaming`)

I would say yes

2. Since there isn't a `QStandardPaths` entry for `XDG_STATE_HOME` (the spec is quite new) and most environments don't "implement" it yet (neither the variable nor the dir itself exist), would it make more sense to use the `AppLocalDataLocation` (`~/.local/share/`) on Linux as well?

again yes especially because I do not think many software already use ~/.local/state (I only see files from pipiwire on my system)

3. _Changing [defaultLogDir](https://github.com/nextcloud/desktop/blob/ca4b4cde61484570ecd7e1cb63e37880e35a5fbf/src/libsync/configfile.cpp#L954) should be sufficient, right?_

You should also test that creating a debug archive for example still work as intended

mgallien commented 3 years ago

@franga2000 https://github.com/nextcloud/desktop/issues/3406#issuecomment-931056464

brainrom commented 1 month ago

Did some research about paths in Nextcloud desktop client. Files, which worth attention: src/gui/accountmanager.cpp - migration of "very old" configs src/gui/application.cpp - migration of old configs src/gui/syncrunfilelog.cpp - writes "nextcloud_sync.log" to QStandardPaths::AppDataLocation, possibly for #6201 src/libsync/account.cpp - creates cookies0.db file in QStandardPaths::AppConfigLocation applicable for #5208 src/libsync/configfile.cpp - sets confDir, ConfigFile::configPath() is used as main path for logs, etc.

In fact, only syncrunfilelog.cpp, account.cpp, configfile.cpp needs changes. This allow to align client with XDG. But what should be done for Mac OS and Windows? Keep current behavior or something else? This solution is enough? https://github.com/nextcloud/desktop/issues/6201#issuecomment-2340450498

Thaodan commented 1 month ago

Ilya @.***> writes:

In fact, only syncrunfilelog.cpp, account.cpp, configfile.cpp needs changes. This allow to align client with XDG. But what should be done for Mac OS and Windows? Keep current behavior or something else? This solution is enough? https://github.com/nextcloud/desktop/issues/6201#issuecomment-2340450498

I think using QStandardPaths::StateLocation is fine as long as there's a compatibility function for Qt below 6.7.