main: system subcommand#537
Open
supakeen wants to merge 2 commits into
Open
Conversation
Introduce a `system` subcommand that we can add additional subcommands to to manage (for example) the cache. Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
Print the current usage of the cache directory. Handle the case of it being unlimited or unknown. Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
0f215dd to
339db78
Compare
avitova
reviewed
Jun 2, 2026
avitova
left a comment
Contributor
There was a problem hiding this comment.
Just a small question. 🤏
achilleas-k
reviewed
Jun 2, 2026
Comment on lines
+53
to
+69
| func calcDirSize(path string) (int64, error) { | ||
| var total int64 | ||
| err := filepath.WalkDir(path, func(_ string, d fs.DirEntry, err error) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if !d.IsDir() { | ||
| info, err := d.Info() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| total += info.Size() | ||
| } | ||
| return nil | ||
| }) | ||
| return total, err | ||
| } |
Member
There was a problem hiding this comment.
osbuild maintains a file in the root of the cache with the current size, so we could read that.
Member
There was a problem hiding this comment.
Though it seems it's updated by calculating writes and deletes, not measuring. I checked mine right now and it's off from the real size on disk by quite a bit. Perhaps a bug for osbuild.
Member
Author
There was a problem hiding this comment.
Both are a bit buggy I think, on the osbuild side and the code in this PR. Especially if mountpoints are set up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Let's add a
systemsubcommand that (initially) shows information about the cache location, its max-size and its current size.This will be a good umbrella subcommand to hang other commands under such as
pruneto clear cache in the future.