Repository navigation
feat: Custom cache path - #19693
feat: Custom cache path#19693emmkimme wants to merge 130 commits into
Conversation
7428712 to
cb1d28f
Compare
4cecaf2 to
2489e09
Compare
dd43fd4 to
fa982fa
Compare
|
@emmkimme it looks like https://github.com/electron/electron/pull/19693/files#diff-c0db39733aba3af6dedd3c8a42082f92 accidentally got changed more than intended? |
You right, I have been again trapped with CR/LF mess on Wndows. I do not get why it happens only on Markdown files, it works for all others. I will fix that. Thanks |
|
Hi @codebytere I fixed MD using my Mac. I deactivated my tests related to setAppLogsPath (BTW original tests are wrong), as it does not work on Windows. If we change the current implem C++ signature from to Removing Another point, AppLogs on Mac takes for application name All others code related to path takes If you agree, I can fix both and reactivate my unit test for applogs. It will fix this issue as well |
596054a to
eedd761
Compare
|
Dear @codebytere, @poiru, @ckerr, reviewers |
eedd761 to
44ff3f4
Compare
|
Hi @MarshallOfSound, |
44ff3f4 to
fd4421d
Compare
|
@jkleinsc |
|
Sorry for that, should be good now (finally!) |
|
BTW @emmkimme you have really gone above & beyond with your persistence on this PR. 🎉 ❤️ |
| Allow to customize Electron/Chromium cache location | ||
| See MR: https://github.com/electron/electron/pull/19693 |
There was a problem hiding this comment.
Per https://www.electronjs.org/docs/development/patches#patch-justification, every patch we carry is a significant ongoing maintenance burden. We ask that the description of a patch includes a justification of why they're worth that maintenance burden, in addition to a description of the functionality that the patch adds.
In order of descending desirability:
- Can this patch be removed entirely by achieving the desired functionality without having to include a patch?
- Can this patch be merged upstream into Chromium itself? (see here for a guide on contributing to Chromium)
- In the patch description, describe the reasons why neither of the above two are possible, and include guidance for a future maintainer looking to clean up patches about how they can check whether this patch is still required (maybe as simple as "if it compiles without this patch, the patch is no longer needed").
Thanks for helping us keep maintaining Electron sustainable 🙇
zcbenz
left a comment
There was a problem hiding this comment.
Session data (like cookies and indexDB) should be considered as user data instead of cache, apps usually store login tokens and un-uploaded works in it. So if we silently change the place where session data are stored in Electron, users will lose login sessions and unsaved works after an app update, which is not acceptable.
It is totally Chromium's fault that it put session data and browser cache in one directory, and is impossible to separate them without a massive patch to Chromium, but I think we can use a different way other than userCache to make things less confusing.
I propose:
- Do not list
userCachein public API. - Add
browserDatapath which is used to store cookies and cache, i.e. the "cache path" in this PR. - The default value of
browserDatashould be the same withuserData.
In this way we can achieve:
- a clear API that does not give a wrong assumption of what "cache" means;
- backward-compatibility without risk losing users' data;
- future-proof that if in future it became possible to separate locations of cookies and caches, we could still introduce
userCachepath.
|
Hi @zcbenz,
|
The electron/shell/app/electron_default_paths.cc Lines 66 to 70 in aef7568 I'm not sure for Windows, but for macOS and Linux the
For desktop apps, cache is usually something that can be safely deleted without affecting current app's state, for example, for a chat app the login session should be kept after deleting the app's cache. This is different from the cache under browser's context, where cookies and sessions are also part of cache. With the name of So I'm proposing using As for separating cookies from other cache, I agree it is error-prone and we should not do it unless it is supported by upstream Chromium. |
|
I'm still looking for a Mac machine for investigating. Should have one soon ! |
Maybe i can help you? I will look through the failing checks. |
That would be great. Lot of thanks. Let me know if you need any help |
# Conflicts: # lib/browser/api/app.ts # shell/app/electron_main_delegate.cc # shell/browser/api/electron_api_app.cc # shell/browser/api/electron_api_app_mac.mm # shell/browser/browser.cc # shell/browser/electron_browser_context.cc # shell/browser/electron_browser_main_parts.cc
|
I did not rebase for 5 months and meanwhile the code change a lot, especially new DIR_* constant appeared and a new management of them. I'm afraid I have to redo this feature from scratch. |
|
Has been closed and replaced by this one: Redirect Electron/Chromium cache location |

Description of Change
This MR fixes the following issues:
Notes: Allow to customize Electron/Chromium cache location
Checklist
npm testpassesTechnical Notes
The notion of cache (DIR_CACHE, DIR_USER_CACHE) is already present in the code but not used.
atom\browser\api\atom_api_app.cc
atom/browser/atom_paths.h
lib\browser\api\app.ts
There is 2 levels of cache :
equivalent to the 2 levels of user data
Purpose was to use the userCache value for customizing the cache
atom\browser\atom_browser_context.cc
Before
After
I added a AppPathService which provides default paths (data, cache, logs) if there are not overridden.
Usage
Backward compatibility
As before, by default,
But not at the same moment. previously it was done very early, before app main script was executed. Now it is done when the app is ready, giving some opportunities to customize 'appData', app name, ..
Previous behavior can be restored easily.
Unit tests
Unit tests are now covering 'userData', 'userCache' and 'logs'.
Additional notes
For concurrent access violation, the cache folder must not be shared by different users.
For performance purpose, it must be set on a fast drive.