Use standardized data directories on linux - #2648
Conversation
related pull reuqest: sourcegit-scm#2088 reasoning behind change: sourcegit-scm#2088 (comment)
SG uses very fiew files, data directory is not crowded yet. but moving the config file to a different directory would hide it from the users who are looking for it after clicking the "Open Data Storage Directory" button in the menu.
would not be used there anyway
|
If you agree to adding a new dependency, I would add |
|
I've pushed my implementation for this feature. There's only one thing left: I keep to store the
|
|
Are you sure XDG_RUNTIME_HOME is automatically cleaned by some distro? In fact, I would expect XDG_CACHE_HOME to be cleaned up periodically. The former is just a tmpfs, everything there is automatically lost on system shutdown. Can I ask which distro have you seen to be running cleanups on XDG_RUNTIME_HOME? Edit: oh, indeed
|
|
I believe the speciifc file mode of 700 only applies to the runtime directory itself:
On my system I have files with all kinds of permission modes set in there, even from modern, generally well behaved software like pipewire, dbus and systemd. The auto cleanup needs to be taken care of, thats right. It kind of makes sense to auto delete unused files, to avoid getting the memory filled up over time, but I think the cleanup routines could at least check additionally whether the file is opened in any process. Because if it is, deletion wont reclaim any space anyway. SourceGit would be using the XDG_RUNTIME_HOME directory very lightly, just a single file and that too always on the same path, so I think it would be okay if you just set the sticky bit on it. But it would still be good to delete the lock file on exit and crashes. I think this is how its done in dotnet: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.setunixfilemode?view=net-10.0 using System;
using System.IO;
string filePath = "/path/to/file";
File.SetUnixFileMode(filePath, File.GetUnixFileMode(filePath) | UnixFileMode.StickyByte); |
|
Done.
You can download the latest CI build from GitHub Action. |
This pull request moves the data directory for linux users to the filesystem location where they will expect it.
General data in
~/.local/share/, cached git username avatars in~/.cache/. Only the former is migrated.I considered moving the config file to
~/.config/but I find the "Open Data Storage Directory" function in the menu useful, and I was torn on whether I should point that to the config directory. Currently the data directory does not hold much, just the avatar caches, the config file, and a lock file (which should probably rather go to/run/user/..., but that depends on its exact purpose), but perhaps more things would be held in this directory, so I didnt want to risk making them less accessible.Detailed reasons for implementing this changes can be read here: #2088 (comment)
This PR is to supersede #2088 . Linux related functionality is handled in the separate Linux.cs file, with respect to the AppImage portable data function.