Print total space saved on nix-store --optimise #2288 #2654
+43
−1
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.
This PR attempts to provide the functionality requested in #2288. I opted to follow the code used i
nix-collect-garbage
but factored it into a private method onLocalStorage
to avoid clutteringoptimiseStore
.I do have one question that might impact this PR beyond any organizational or stylistic blunders: How accurately is accurate enough for on disk storage?
nix-collect-garbage
usesst_blocks * 512ULL
, which will be accurate for the usual case.optimiseStore
usesst_size
, which will be similar (though possibly less honest about the disk usage).In a case with a block size that isn't the usual 512 (i.e. networked storages, etc.), the reported number could not reflect the actual size on disk well at all, which would beg for a query to
st_blksize
For now, I used
st_size
to be consistent withinoptimise-store.cc
, which means it gives a slightly different answer than the same text in used ingc.cc
.Happy to make any changes and correct rookie mistakes.