Skip to content

Commit

Permalink
cli/delete-cache: Use parallelized version of filepath.Walk
Browse files Browse the repository at this point in the history
Keeps the same API usage, just faster.

Resolves #89.

solbuild dc -s ('41.8 GiB')

Before : 0m15.849s (uncached) | 0m6.241s (cached)
After  : 0m2.134s (uncached)  | 0m0.585s (cached)
  • Loading branch information
joebonrichie committed Mar 16, 2024
1 parent 8f39302 commit 13ab35c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli/delete_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"log/slog"
"math"
"os"
"path/filepath"

"github.com/DataDrake/cli-ng/v2/cmd"

"github.com/getsolus/solbuild/builder"
"github.com/getsolus/solbuild/builder/source"
"github.com/getsolus/solbuild/cli/log"

"github.com/MichaelTJones/walk"
)

func init() {
Expand Down Expand Up @@ -161,7 +162,7 @@ func getDirSize(path string) (int64, error) {
}

// Walk the dir, get size, add to totalSize
err = filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
err = walk.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (

require (
dario.cat/mergo v1.0.0 // indirect
github.com/MichaelTJones/walk v0.0.0-20161122175330-4748e29d5718 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DataDrake/cli-ng/v2 v2.0.2 h1:7+25l25VmlERCE95glW6QKBUF13vxqAM2jasFiN02xQ=
github.com/DataDrake/cli-ng/v2 v2.0.2/go.mod h1:bU9YaNNWWVq0eIdDsU3TCe9+7Jb398iBBoqee5EiKWQ=
github.com/MichaelTJones/walk v0.0.0-20161122175330-4748e29d5718 h1:FSsoaa1q4jAaeiAUxf9H0PgFP7eA/UL6c3PdJH+nMN4=
github.com/MichaelTJones/walk v0.0.0-20161122175330-4748e29d5718/go.mod h1:VVwKsx9Dc8rNG55BWqogoJzGubjKnRoXdUvpGbWqeCc=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
Expand Down

0 comments on commit 13ab35c

Please sign in to comment.