mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat(linux): Use XDG_STATE_HOME to storage logs
This commit is contained in:
parent
d359d130de
commit
e9479b1dcf
@ -64,6 +64,11 @@ class AppLogger {
|
||||
if (kIsMacOS) {
|
||||
dir = join((await getLibraryDirectory()).path, "Logs");
|
||||
}
|
||||
|
||||
if (kIsLinux) {
|
||||
dir = join(_getXdgStateHome(), "spotube");
|
||||
}
|
||||
|
||||
final file = File(join(dir, ".spotube_logs"));
|
||||
if (!await file.exists()) {
|
||||
await file.create(recursive: true);
|
||||
@ -87,4 +92,18 @@ class AppLogger {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static String _getXdgStateHome() {
|
||||
// path_provider seems does not support XDG_STATE_HOME,
|
||||
// which is the specification to store application logs on Linux.
|
||||
// See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
// TODO: Use path_provider once it supports XDG_STATE_HOME
|
||||
if (bool.hasEnvironment("XDG_STATE_HOME")) {
|
||||
String xdgStateHomeRaw = String.fromEnvironment("XDG_STATE_HOME");
|
||||
if (!xdgStateHomeRaw.isEmpty) {
|
||||
return xdgStateHomeRaw;
|
||||
}
|
||||
}
|
||||
return join(String.fromEnvironment("HOME"), ".local", "state");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user