Skip to content

Commit

Permalink
Revert "Fix: Remove recursive stat to improve volume api requests (#8… (
Browse files Browse the repository at this point in the history
#869)

…64)"

This reverts commit 1007780.
  • Loading branch information
jsun-m authored Jan 17, 2025
1 parent a573bc9 commit 9a6e29e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/abstractions/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ func (vs *GlobalVolumeService) listVolumes(ctx context.Context, workspace *types
return nil, err
}

for i, v := range volumes {
path := JoinVolumePath(workspace.Name, v.ExternalId)

size, err := CalculateDirSize(path)
if err != nil {
size = 0
}

volumes[i].Size = size
}

return volumes, nil
}

Expand Down Expand Up @@ -459,6 +470,10 @@ func (vs *GlobalVolumeService) listPath(ctx context.Context, inputPath string, w
for i, p := range matches {
info, _ := os.Stat(p)
size := info.Size()
if info.IsDir() {
s, _ := CalculateDirSize(p)
size = int64(s)
}
files[i] = FileInfo{
Path: strings.TrimPrefix(p, rootVolumePath+"/"),
Size: uint64(size),
Expand Down

0 comments on commit 9a6e29e

Please sign in to comment.