magiruuvelvet / cache-management

A work-in-progress utility to tame package managers and keep your caches under control. Because your storage is not free real estate.
MIT License
0 stars 0 forks source link

wildcard matching #8

Closed magiruuvelvet closed 1 year ago

magiruuvelvet commented 1 year ago

Instead of having to match a single directory per cache mapping, it would also be nice to allow wildcard matching and matching of regular files. I had this idea after observing a huge amount of .pch files produced by clangd, wasting over 500MB of storage in /tmp (tmpfs).

This allows to add such temporary garbage to the cache reporting tool to find storage wasters more quickly.

magiruuvelvet commented 1 year ago

Wildcard matching was implemented with the following commits:

c72c63104da8023c3e071e890d2843762cc2d873 a68ef6f894e5eb4765bc17a1bbdf50ae80219183 faf67b974d2fd09bf7f79bbd214eff719c698177 6304e24258bb417893c1fce61f862bfbb72dca32

There is still room for improvement and code clean up should be done, especially in the command line application, but it generally works.

Expample output:

# ./cachemgr -u
Calculating usage statistics...
/tmp/preamble-*.pch :  88.02MB (88021652 bytes)

cache mapping in configuration file:

cache_mappings:
  # clangd precompiled headers cache
  - type: clangd-pch-cache
    source: /tmp/preamble-*.pch
magiruuvelvet commented 1 year ago

Use target for wildcard matching for consistency. Wildcard cache mappings are now treated similar to standalone caches.

77c5d8419442d8ce8d2ed1a1aff3fe64be15704e 5499b2b9a4000f189660416ecdc3f4f63871fcec

cache_mappings:
  # clangd precompiled headers cache
  - type: clangd-pch-cache
    target: /tmp/preamble-*.pch
magiruuvelvet commented 1 year ago

The core logic is implemented. Simplifications for the entire parsing process and how cache mappings are handled in general are planned. This ticket can be closed.