feat: A helper to clean broken cache entries.
WhyNotHugo opened this issue · 3 comments
I'd like a script that goes through all cached entries and deletes any that no longer exist (e.g.: deleted desktop entries).
I'm wondering if some user or contributor already has a script that does that.
I like the idea, but it would need to work with any kind of provider. Not every provider is file-based so we cannot make a generic solution for everything. An idea would be to add another validate_cmd
to any provider which returns 0 if a given entry is still valid and 1 if it isn't. I guess there would be some sway-launcher-desktop.sh prune
command that iterates over the cache file and calls the verify_cmd
of the corellating provider of each entry - exposed as template variable {1}
.
This could then be set up as a cronjob, pacman hook or something like that.
An idea would be to add another validate_cmd to any provider which returns 0 if a given entry is still valid and 1 if it doesn't.
This is the kind of idea I was hoping to hear, sounds like a very simple yet flexible approach.
I created a feature branch that introduces the purge
function. It iterates over the current history file and weeds out every entry that does not pass a specified filter callback.
As of now, this has a couple of limitations:
- untested
- no documentation
- only works on the builtin providers. Parsing a custom PROVIDERS_FILE
still needs to be implemented