Count every file of each version in secret info's Total Size (closes #147)
check / check (push) Canceled after 0s

Total Size added up each version's data.age and metadata.age, but a
version keeps its value in value.age, so no secret's value was counted.
It now adds up every file in each version directory: the value, the
metadata and the version's two keys, as the plan on the issue decided.
A version directory that cannot be read still adds nothing.

The new test adds a 10000-byte secret and checks that the total grows by
at least that much.

Model: opus-5-5
This commit is contained in:
2026-10-14 22:20:07 +00:00
parent 72cd6c30a1
commit 54ec8dfe5a
2 changed files with 72 additions and 15 deletions
+8 -15
View File
@@ -18,24 +18,17 @@ type vaultStats struct {
// addVersion accumulates size and timestamp info for one version directory
func (s *vaultStats) addVersion(fs afero.Fs, versionPath string) {
// Add size of encrypted data
dataPath := filepath.Join(versionPath, "data.age")
stat, err := fs.Stat(dataPath)
if err == nil {
s.totalSize += stat.Size()
}
// Add size of metadata
metaPath := filepath.Join(versionPath, "metadata.age")
stat, err = fs.Stat(metaPath)
if err == nil {
s.totalSize += stat.Size()
// Add the size of every file in the version directory: its value,
// metadata and keys. A directory that cannot be read adds nothing.
files, _ := afero.ReadDir(fs, versionPath)
for _, file := range files {
if !file.IsDir() {
s.totalSize += file.Size()
}
}
// Track timestamps
stat, err = fs.Stat(versionPath)
stat, err := fs.Stat(versionPath)
if err == nil {
modTime := stat.ModTime()
if s.oldestTime.IsZero() || modTime.Before(s.oldestTime) {