XDG Base Directory Specification
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
XDG Base Directory Specification
There was a long pending ticket in the bug tracker issue #2956 that has been implemented with git commit e7e2994ba.
This mainly affects Linux users where config and data files are no longer written to $HOME/.FreeCAD. Instead config files now go to $HOME/.config/FreeCAD, data files go to $HOME/.local/share/FreeCAD and temporary files go to $HOME/.cache/FreeCAD/Cache. The latter were written to /tmp in the past and thus got deleted after a reboot. So, now they will survive a reboot.
For macOS users the user.cfg has already been at the correct location under ~/Library/Preferences/FreeCAD but data files go to ~/Library/Application Support/FreeCAD (at least this is what the Qt doc says).
For your convenience the user.cfg will be copied from the old to the new location but it's up to you to manually transfer all other files to their new destination. This affects 3rd party macros and workbenches you have installed via the add-on manager.
In case you want the old behaviour back you can use the program option: --keep-deprecated-paths
This mainly affects Linux users where config and data files are no longer written to $HOME/.FreeCAD. Instead config files now go to $HOME/.config/FreeCAD, data files go to $HOME/.local/share/FreeCAD and temporary files go to $HOME/.cache/FreeCAD/Cache. The latter were written to /tmp in the past and thus got deleted after a reboot. So, now they will survive a reboot.
For macOS users the user.cfg has already been at the correct location under ~/Library/Preferences/FreeCAD but data files go to ~/Library/Application Support/FreeCAD (at least this is what the Qt doc says).
For your convenience the user.cfg will be copied from the old to the new location but it's up to you to manually transfer all other files to their new destination. This affects 3rd party macros and workbenches you have installed via the add-on manager.
In case you want the old behaviour back you can use the program option: --keep-deprecated-paths
Re: XDG Base Directory Specification
I do not know, if that is a good idea. In CAD often big files and temp data incur, especially in FEM. This can overload HDD (or SDD) pretty fast und is unnecessary data, which must deleted per hand. Also if there is a flag, that deletes the data automatic while closing FreeCAD, in can happen, especially on fragile operation with big files, that FreeCAD crashes and then the dump is still on the disk.
Just my thoughts.
Greetings
user1234
edit: also the /tmp can be a separate disc and with the new behavior dump can land on the /home disc, where it should not be.
Re: XDG Base Directory Specification
From time to time there were complaints about adding the files to /tmp because in certain cases when the system runs out of memory it had to be rebooted after a reset and thus the user lost all his data.Also if there is a flag, that deletes the data automatic while closing FreeCAD, in can happen, especially on fragile operation with big files, that FreeCAD crashes and then the dump is still on the disk.
At least when FreeCAD doesn't crash then all files inside the transient directory of a document will be properly cleaned-up. If it has crashed then the recovery dialog comes up the next time where the user can clean-up all left-overs.
I am not sure in how far FEM files are affected by this. Most of this part is written in Python and the code may use the Python API so that files still go to /tmp.
But nevertheless the user has the possibility to override the default location of temp. files by setting the user config parameter BaseApp/Preferences/General/TempPath to point it to /tmp
Re: XDG Base Directory Specification
I still do not think, that the home directory/disk is a valid place for temp files for a CAD, also when there are settings to overrule them. The parameters are pretty hidden and the user can only find them, when he know, that there are settings for that (OK, the last point count for every setting, but the parameters are really very pretty invisible).
Greetings
user1234
Greetings
user1234
Re: XDG Base Directory Specification
Are AddOns data files under this scheme? What is the correct variable for me to use in the AddonManager to make sure it's putting things in the right place? And do you want me to add migration to it?
Re: XDG Base Directory Specification
Well, but the XDG specification says something else. It does not even mention /tmp anywhere.
Other applications that usually caches many files are browsers and all of them put the data underneath the HOME directory.
We can make the setting more prominent by adding it to the preferences dialog and there we can also add a button to manually clear the whole content of the cache directory.The parameters are pretty hidden and the user can only find them, when he know, that there are settings for that (OK, the last point count for every setting, but the parameters are really very pretty invisible).
Re: XDG Base Directory Specification
Yes, Addons are affected by this change. In the past they have been put to $HOME/.FreeCAD/Mod (for workbenches) or $HOME/.FreeCAD/Macro for simple macros. With the change they will be put to $HOME/.local/share/FreeCAD/Mod or $HOME/.local/share/FreeCAD/Macro.
Ideally there is nothing to change at all if the AddonManager uses the suitable functions. These are App.getUserAppDataDir() that returns $HOME/.local/share/FreeCAD and a special function for macros App.getUserMacroDir(True).
The user is allowed to configure the macro path and that's why True should be passed to App.getUserMacroDir() to read the user setting. If you don't pass an argument or False App.getUserMacroDir() returns the default path $HOME/.FreeCAD/Macro.
The only new function is App.getUserConfigDir() that returns $HOME/.config/FreeCAD and there we store user.cfg, system.cfg and FreeCAD.conf (created by Qt's QSettings class).
EDIT:
The AddonManager puts cached images to $HOME/.local/share/FreeCAD/AddonManager/Images/. Maybe the more appropriate location would be $HOME/.cache/FreeCAD/Cache/AddonManager/Images/.
However, I have to implement a function first to access it from Python.
Re: XDG Base Directory Specification
Well, this specification is for something like browers or anything, where you can grap important securety datas. This is in FreeCAD with the temp files per se not the case, exception are of course real.wmayer wrote: ↑Fri Nov 12, 2021 10:45 am Well, but the XDG specification says something else. It does not even mention /tmp anywhere.
Other applications that usually caches many files are browsers and all of them put the data underneath the HOME directory.
This would be suberb! With that, you can set the temp files also in a place, where only the user only have access and with that you can eliminate the very rare exception. Also many programs have this option placed in the nornal settings.
Greetinga
user1234
Re: XDG Base Directory Specification
Once you do I will amend PR 5131 to use that cache location. The AddonManager already does use App.getUserAppDataDir() for Mods, so it's good to know that code won't change. Do you think I should implement migration from the old location to the new, for pre-existing installed mods? If so, I'll also need access to the old location via Python.wmayer wrote: ↑Fri Nov 12, 2021 11:02 am EDIT:
The AddonManager puts cached images to $HOME/.local/share/FreeCAD/AddonManager/Images/. Maybe the more appropriate location would be $HOME/.cache/FreeCAD/Cache/AddonManager/Images/.
However, I have to implement a function first to access it from Python.
- adrianinsaval
- Veteran
- Posts: 5548
- Joined: Thu Apr 05, 2018 5:15 pm
Re: XDG Base Directory Specification
Macros seem to still be picked up from ~/.FreeCAD/Macros ?