Separate cache dir from Maxima data dir#45
Separate cache dir from Maxima data dir#45p0358 wants to merge 2 commits intoArmchairDevelopers:masterfrom
Conversation
maxima-lib/src/util/native.rs
Outdated
| let home = if let Ok(home) = env::var("XDG_CACHE_HOME") { | ||
| home | ||
| } else if let Ok(home) = env::var("HOME") { | ||
| format!("{}/.cache", home) |
There was a problem hiding this comment.
i would keep in mind that cfg(unix) applies to macOS as well, under which ~/Library/Caches would be the right path
not a huge deal as we don't officially support macOS yet, but i'd avoid stacking up future issues for that when the rest of the codebase is fairly friendly on it
There was a problem hiding this comment.
Very fair point actually, but I'm seeing this applies to current maxima_dir() too, where it seems on macOS it's probably supposed to use ~/Library/Application Support instead of ~/.local/share.
In fact, in this case, it seems that our library would apply the exact same logic and outcome on Linux as well:
- https://docs.rs/directories/latest/directories/struct.ProjectDirs.html#method.data_dir
- https://docs.rs/directories/latest/directories/struct.ProjectDirs.html#method.cache_dir
That means the easiest solution will be to just drop the Unix variant and rely on the ProjectDirs. And I guess I'll add some unit tests for that, since I wouldn't feel that comfortable just leaving it like that without some direct documentation what the paths are expected to be.
headassbtw
left a comment
There was a problem hiding this comment.
see previous comment, but LGTM otherwise. sorry for the delay on reviewing, i've been slammed at work
… up with what we had on Linux (includes unit tests to ensure that's the case)
|
No worries, been slammed too. I don't have a setup on Windows, so would appreciate if someone could run the unit test on Windows just to be sure too: No paths should have changed in Windows at all, and on Linux between my first and second commit, but always better safe than sorry. |
|
@headassbtw anything stopping this from getting merged? |
|
I'd been meaning to run these tests on windows/OSX but frankly got distracted. i'm doing that rn, if they pass then all's good to me |
|
OSX: Windows: The path separators in the test are wrong on windows, but that's pedantic and i don't care. LGTM |
So that it doesn't put these files into people's backups.
There were
cache,tempanddownloadssub-dirs previously, all ephemeral. I've put contents of first two directly into~/.cache/maximaand the last one still as sub-dir.I'm only unsure about
download_queue.json, but it feels like it'd be better off also being in cache (if someone wiped cache during a download, it might not necessarily be safe to assume whatever download was going can be just resumed like that, because maybe they just restored their system from a backup after re-setting it up again, maybe game dirs are gone too, etc.)Technically downloader and its queue could go into a state dir, but I think that would be overkill at that point, so let's keep things simple.
As for Windows, data_dir() is
{FOLDERID_RoamingAppData}\_project_path_\data, while cache_dir() is{FOLDERID_LocalAppData}\_project_path_\cache. Well, I guess Origin/EA App do separate their files between these two in a similar fashion, I recall they were putting cached avatars into %LocalAppData% too...