fix: use DiskUsage instead of VolumeList to populate Volume.UsageData

This commit is contained in:
glav-git 2026-01-25 19:58:22 +02:00
parent 577797d9ed
commit b06f7d0fe6
2 changed files with 3 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package commands
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
@ -21,7 +22,7 @@ type Volume struct {
// RefreshVolumes gets the volumes and stores them
func (c *DockerCommand) RefreshVolumes() ([]*Volume, error) {
result, err := c.Client.VolumeList(context.Background(), volume.ListOptions{})
result, err := c.Client.DiskUsage(context.Background(), types.DiskUsageOptions{Types: []types.DiskUsageObject{types.VolumeObject}})
if err != nil {
return nil, err
}

View file

@ -78,7 +78,7 @@ func (gui *Gui) volumeConfigStr(volume *commands.Volume) string {
}
if volume.Volume.UsageData != nil {
output += utils.WithPadding("RefCount: ", padding) + fmt.Sprintf("%d", volume.Volume.UsageData.RefCount) + "\n"
output += "\n" + utils.WithPadding("RefCount: ", padding) + fmt.Sprintf("%d", volume.Volume.UsageData.RefCount) + "\n"
output += utils.WithPadding("Size: ", padding) + utils.FormatBinaryBytes(int(volume.Volume.UsageData.Size)) + "\n"
}