Skip to content

fix: centralize cache file registry#1370

Open
mavonx wants to merge 6 commits into
floatpane:masterfrom
mavonx:fix/issue-564
Open

fix: centralize cache file registry#1370
mavonx wants to merge 6 commits into
floatpane:masterfrom
mavonx:fix/issue-564

Conversation

@mavonx
Copy link
Copy Markdown
Member

@mavonx mavonx commented May 27, 2026

What?

Replaces the hardcoded file list inside MigrateCacheFiles() with two package-level registries: cacheFiles for JSON cache files and cacheDirectories for cache subdirectories.

Why?

Previously, adding a new cache file to the project required finding and updating the hardcoded list inside MigrateCacheFiles(). This was easy to forget and caused files to be silently left behind in the old ~/.config/matcha/ location after migration. Now there is a single obvious place to register new cache paths.

Closes #564

@mavonx mavonx requested a review from a team as a code owner May 27, 2026 21:31
@floatpanebot floatpanebot added bug Something isn't working area/config Configuration / settings size/S Diff: 11–50 lines labels May 27, 2026
@floatpanebot
Copy link
Copy Markdown
Member

floatpanebot commented May 27, 2026

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 9V74 80-Core Processor                
                           │    old.txt    │              new.txt               │
                           │    sec/op     │    sec/op     vs base              │
ParseSearchQuery_Simple-4    2.995µ ± 219%   2.666µ ± 37%       ~ (p=0.180 n=6)
ParseSearchQuery_Complex-4   7.844µ ±  56%   9.273µ ± 14%       ~ (p=0.065 n=6)
TokenizeSearchQuery-4        4.173µ ±  85%   4.278µ ± 86%       ~ (p=0.937 n=6)
geomean                      4.611µ          4.729µ        +2.56%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │    old.txt    │              new.txt               │
                    │    sec/op     │    sec/op     vs base              │
LogPanelView-4         171.5µ ±  9%   158.2µ ±  8%       ~ (p=0.093 n=6)
SearchOverlayView-4    182.6µ ±  7%   169.4µ ±  4%  -7.26% (p=0.015 n=6)
InboxConstruction-4   1008.5µ ± 27%   996.7µ ± 28%       ~ (p=0.699 n=6)
geomean                316.1µ         298.9µ        -5.44%

                    │    old.txt    │               new.txt                │
                    │     B/op      │     B/op       vs base               │
LogPanelView-4        33.23Ki ± 34%   44.67Ki ± 51%        ~ (p=1.000 n=6)
SearchOverlayView-4   56.14Ki ±  0%   56.14Ki ± 41%        ~ (p=0.076 n=6)
InboxConstruction-4   874.3Ki ±  0%   874.3Ki ±  0%        ~ (p=0.816 n=6)
geomean               117.7Ki         129.9Ki        +10.36%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         713.0 ± 0%    714.0 ± 0%       ~ (p=1.000 n=6)
SearchOverlayView-4    926.0 ± 0%    926.0 ± 0%       ~ (p=0.273 n=6)
InboxConstruction-4   3.478k ± 0%   3.478k ± 0%       ~ (p=0.636 n=6)
geomean               1.319k        1.320k       +0.05%

auto-generated by benchmarks.yml

@floatpanebot floatpanebot added the size/M Diff: 51–200 lines label May 27, 2026
@mavonx
Copy link
Copy Markdown
Member Author

mavonx commented May 27, 2026

@andrinoff

Please mark this PR as draft temporarily. I noticed the same thing needs to be refactored in some other places as well.

@andrinoff
Copy link
Copy Markdown
Member

@mavonx you can and should convert yourself

@mavonx mavonx marked this pull request as draft May 28, 2026 07:24
@mavonx mavonx marked this pull request as ready for review May 28, 2026 09:07
@mavonx
Copy link
Copy Markdown
Member Author

mavonx commented May 28, 2026

@andrinoff

Ready for review.

@andrinoff
Copy link
Copy Markdown
Member

@mavonx join the Discord, please, we communicate there, there is also an audit log

Comment thread config/encryption.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

collectDataFiles still has the directory names hardcoded (also in bodyDir and sigDir) loop over them too

@mavonx mavonx marked this pull request as draft May 28, 2026 16:01
@mavonx mavonx marked this pull request as ready for review May 28, 2026 16:04
@mavonx
Copy link
Copy Markdown
Member Author

mavonx commented May 28, 2026

@andrinoff

The signatures part is not related to centralized caching folders or files, so I didn’t touch it.

@mavonx mavonx requested a review from andrinoff May 28, 2026 16:05
@andrinoff andrinoff requested review from FromSi and removed request for andrinoff May 28, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Configuration / settings bug Something isn't working size/M Diff: 51–200 lines size/S Diff: 11–50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: MigrateCacheFiles list is incomplete/static

3 participants