mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-16 12:03:21 +00:00
fix: fix code review issues
This commit is contained in:
parent
26b5d2966d
commit
2db57d0507
5 changed files with 310 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ func (d *Daemon) GetStorageReport(ctx context.Context) (*contracthost.GetStorage
|
|||
}{
|
||||
{name: contracthost.StoragePoolArtifacts, path: d.config.ArtifactsDir},
|
||||
{name: contracthost.StoragePoolMachineDisks, path: d.config.MachineDisksDir},
|
||||
{name: contracthost.StoragePoolPublishedPort, path: ""},
|
||||
{name: contracthost.StoragePoolSnapshots, path: d.config.SnapshotsDir},
|
||||
{name: contracthost.StoragePoolState, path: filepath.Dir(d.config.StatePath)},
|
||||
} {
|
||||
|
|
@ -133,8 +134,14 @@ func directorySize(root string) (int64, error) {
|
|||
}
|
||||
|
||||
func fileSize(path string) (int64, error) {
|
||||
if path == "" {
|
||||
return 0, nil
|
||||
}
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return 0, nil
|
||||
}
|
||||
return 0, fmt.Errorf("stat %q: %w", path, err)
|
||||
}
|
||||
return info.Size(), nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue