Repository navigation
Conversation
erickzhao
left a comment
There was a problem hiding this comment.
first pass at docs review! :)
MarshallOfSound
left a comment
There was a problem hiding this comment.
My comments in that really old issue still stand, without some kind of migration all we're doing is:
- Putting apps into an unkown state
- Massively duplicating content on disk
- Potentially breaking existing backup / storage systems that depend on our existing paths
For very little gain (it's just "semantic correctness"). I like the idea of adding more path customization, I don't like changing the defaults
|
For what it's worth, I believe the tutorial part of this PR could also be standalone. Giving users a blessed guide for data storage techniques is worthwhile even without the additional path customization provided in the feature code. |
|
@MarshallOfSound That is quite valid concern. I have changed this PR to provide an API to change the cache location, instead of changing the default location. |
| * `userCache` The directory for storing your app's cache files, which | ||
| by default is the `cache` directory appended with your app's name. HTTP disk | ||
| cache and JavaScript code cache are written into this directory. |
There was a problem hiding this comment.
The userCache name is a little unclear to me since cache is already per-user...?
I feel like cache and appCache might be a little clearer but if there are Good Reasons for using userCache I wouldn't block on this
There was a problem hiding this comment.
The name follows the name convention of appData/userData paths, which came from the DIR_APP_DATA/DIR_USER_DATA paths in Chromium, and which very likely came from the %APPDATA% env on Windows.
| * On Windows, there is no specialized location to store cache data, and most apps | ||
| write cache data to `%LOCALAPPDATA%`, so this path points to `localUserData` by | ||
| default. If your app is writing files to both `localUserData` and `userCache`, | ||
| you should consider changing the `userCache` path to a subdirectory of | ||
| `localUserData` to avoid conflicts. |
There was a problem hiding this comment.
This is a very good description of the nuance here 👍
| @@ -0,0 +1,100 @@ | |||
| # Where to Store App Data | |||
| let partition; | ||
| if (process.argv.length > 3) { | ||
| app.setPath(process.argv[2], process.argv[3]); | ||
| if (process.argv.length > 4) { | ||
| partition = 'persist:' + process.argv[4]; | ||
| } |
There was a problem hiding this comment.
We're getting to a point where maybe we want to consider arg parsing in this main.js
0f5a2c4 to
fa52286
Compare
9bb44a5 to
64cd069
Compare
|
/cc @electron/wg-api for API review. |
|
There is a problem in several installers, there is no possibility to select the installation folder. 32-bit and 64-bit:
Important:
For example, Mozilla Firefox has:
More informations about folders in Microsoft Windows: 1/ %PROGRAMFILES% is a folder first found in Microsoft Windows 95 and included in all later versions of Microsoft Windows that stores the software programs installed on the computer. 2/ %USERNAME%\AppData
Thanks in advance. |
Co-authored-by: Erick Zhao <[email protected]>
Co-authored-by: Charles Kerr <[email protected]>
64cd069 to
24e3016
Compare
There was a problem hiding this comment.
I’m glad to see someone tries to help Electron apps to store their data following approved standards. Thanks for tackling that.
However, while reading through your documentation, I discovered you seem to consider to use CONFIG (shorthand for $XDG_*_HOME) to use for localUserData, where “user data [can take] lots of disk space”. This would manifest issues like #8124, not with cache but with important binary data (like images). I created a comment at those lines with the reasoning.
| As a rule of thumb, if some user data takes lots of disk space, it should be written | ||
| to `localUserData`. Otherwise, it should instead be written to `userData`. | ||
|
|
||
| On Linux and macOS, `localUserData` has no distinctive purpose and is just an alias |
There was a problem hiding this comment.
Following XDG Base Directory Spec, this should be DATA, maybe STATE, but definitly not CONFIG.
$XDG_DATA_HOMEis for generic user data, without further specification. Rather than CONFIG, DATA should be bloated with important, but big amounts of data. Some users still synchronize them, but then they know what they are doing.$XDG_CONFIG_HOMEis for configuration files, which users may sync between their computers. some even consider CONFIG to be exclusively for text files (so it can be easily included in dotfiles repositories). So this directory should not be bloated with big files on Linux, similar to%APPDATA%on Windows.$XDG_STATE_HOMEshould contain “data that should persist between (application) restarts, but that is not important or portable enough to the user that is should be stored in$XDG_DATA_HOME”. But mind, STATE is considered similar to CACHE, these are not completely redundant, but it may only a minor inconvenience should these get lost.
Size Comparisons
PS: To add examples from the practice:
$ du -sh $XDG_DATA_HOME $XDG_CONFIG_HOME $XDG_STATE_HOME
46G /home/zocker/.local/share # DATA
4,5G /home/zocker/.config # CONFIG
64K /home/zocker/.local/state # STATE
But my CONFIG just so big because of (Electron) apps not respecting XDG:
$ du -sh .config/* | sort -rh | head -n 6
3,0G .config/Code # electron
553M .config/discord # electron
207M .config/chromium # parent of electron
158M .config/SchildiChat # electron
157M .config/unity3d # first non-electron
151M .config/Element # electron
Excluding those biggest 6 outliers (and IMHO there are more) my CONFIG dir would just use 310 MiB. So real thanks for fixing Electron apps ❤️.
|
This will create more fragmentation. Some apps will support proper layout, some wont. Electron really should fix bad defaults instead. |
|
Thanks for working on this! |
|
The current understanding is that the changes to Also, I'm tagging this PR as wip since it's not actively being worked on. If anyone is interested in taking on this work, please let |
|
@zcbenz: Why have you closed your PR? |
|
I'm tired of pushing this. |
|
@zcbenz would you be ok with someone else taking over the feature? |
|
Of course not, please feel free continuing the work. |
Description of Change
Close #1404.
Close #8124.
This PR does following things:
cache,userCache,localUserData.sessionCachedir which can be used to change where HTTP disk cache and JavaScript code cache are stored.Note that we still have a few other kinds of cache left in
userDatalike GPU cache and WebRTC logs, it is hard to find out how to change their locations all at once and I would like to do it in followup PRs.Release Notes
Notes: Add
cache/userCache/localUserData/sessionCachepaths toapp.setPathwhich can be used to customize positions of various cache data.