Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Measure and log the time used to remove all child directories #335

Merged
merged 1 commit into from Jun 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/snapshot/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/uber/makisu/lib/log"
"github.com/uber/makisu/lib/mountutils"
Expand Down Expand Up @@ -119,13 +120,15 @@ func removePathRecursive(p string, fi os.FileInfo, blacklist []string) bool {
// removeAllChildren recursively removes all of the files that it can under the given root.
// It skips paths in the given blacklist and continues when it fails to remove a file.
func removeAllChildren(srcRoot string, blacklist []string) error {
start := time.Now()
children, err := ioutil.ReadDir(srcRoot)
if err != nil {
return fmt.Errorf("failed to get children of %s: %s", srcRoot, err)
}
for _, child := range children {
removePathRecursive(filepath.Join(srcRoot, child.Name()), child, blacklist)
}
log.Infow(fmt.Sprintf("* Removed %d directories under %s", len(children), srcRoot), "duration", time.Since(start).Round(time.Millisecond))
return nil
}

Expand Down