Skip to content

Separate cache dir from Maxima data dir#45

Open
p0358 wants to merge 2 commits intoArmchairDevelopers:masterfrom
p0358:patch-cache-dir
Open

Separate cache dir from Maxima data dir#45
p0358 wants to merge 2 commits intoArmchairDevelopers:masterfrom
p0358:patch-cache-dir

Conversation

@p0358
Copy link

@p0358 p0358 commented Jan 26, 2026

So that it doesn't put these files into people's backups.

There were cache, temp and downloads sub-dirs previously, all ephemeral. I've put contents of first two directly into ~/.cache/maxima and 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...

let home = if let Ok(home) = env::var("XDG_CACHE_HOME") {
home
} else if let Ok(home) = env::var("HOME") {
format!("{}/.cache", home)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

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.

Copy link
Member

@headassbtw headassbtw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
@p0358
Copy link
Author

p0358 commented Feb 4, 2026

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:

cargo test -- --nocapture
running 4 tests
[test_maxima_cache_dir] Expected: "/home/p0358/.cache/maxima" Got: "/home/p0358/.cache/maxima"
[test_maxima_dir] Expected: "/home/p0358/.local/share/maxima" Got: "/home/p0358/.local/share/maxima"
test util::native::tests::test_maxima_cache_dir ... ok
test util::native::tests::test_maxima_dir ... ok

No paths should have changed in Windows at all, and on Linux between my first and second commit, but always better safe than sorry.

@p0358 p0358 requested a review from headassbtw February 4, 2026 19:55
@wannkunstbeikor
Copy link
Collaborator

@headassbtw anything stopping this from getting merged?

@headassbtw
Copy link
Member

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

@headassbtw
Copy link
Member

OSX:

[test_maxima_cache_dir] Expected: "/Users/user00/Library/Caches/com.ArmchairDevelopers.Maxima" Got: "/Users/user00/Library/Caches/com.ArmchairDevelopers.Maxima"
test util::native::tests::test_maxima_cache_dir ... ok
[test_maxima_dir] Expected: "/Users/user00/Library/Application Support/com.ArmchairDevelopers.Maxima" Got: "/Users/user00/Library/Application Support/com.ArmchairDevelopers.Maxima"
test util::native::tests::test_maxima_dir ... ok

Windows:

[test_maxima_dir] Expected: "C:\\Users\\Martin Hatch\\AppData\\Roaming/ArmchairDevelopers/Maxima/data" Got: "C:\\Users\\Martin Hatch\\AppData\\Roaming\\ArmchairDevelopers\\Maxima\\data"
[test_maxima_cache_dir] Expected: "C:\\Users\\Martin Hatch\\AppData\\Local/ArmchairDevelopers/Maxima/cache" Got: "C:\\Users\\Martin Hatch\\AppData\\Local\\ArmchairDevelopers\\Maxima\\cache"

The path separators in the test are wrong on windows, but that's pedantic and i don't care. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants