Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement windows parser and on drive letter #206

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions pkg/filesystem/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ go_library(
],
"@rules_go//go/platform:windows": [
"//pkg/filesystem/windowsext",
"//pkg/util",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
"@org_golang_x_sys//windows",
Expand Down
16 changes: 11 additions & 5 deletions pkg/filesystem/local_directory_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/buildbarn/bb-storage/pkg/filesystem/path"
"github.com/buildbarn/bb-storage/pkg/filesystem/windowsext"
"github.com/buildbarn/bb-storage/pkg/util"

"golang.org/x/sys/windows"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -586,32 +587,37 @@ func (d *localDirectory) Remove(name path.Component) error {

// On NTFS mount point is a reparse point, no need to unmount.
func (d *localDirectory) RemoveAllChildren() error {
return d.removeAllChildren(nil)
}

func (d *localDirectory) removeAllChildren(dPath *path.Trace) error {
defer runtime.KeepAlive(d)

names, err := readdirnames(d.handle)
if err != nil {
return err
return util.StatusWrapf(err, "Failed to read contents of directory %#v", dPath.GetUNIXString())
}
for _, name := range names {
component := path.MustNewComponent(name)
fileType, err := d.lstat(component)
childPath := dPath.Append(component)
if err != nil {
return err
return util.StatusWrapf(err, "Failed to stat component %#v", childPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/component//, because it's not actually a path component but a full path? Also add .GetUNIXString(). Same with the other calls below.

}
if fileType == FileTypeDirectory {
subdirectory, err := d.enter(component, true)
if err != nil {
return err
return util.StatusWrapf(err, "Failed to enter component %#v", childPath)
}
err = subdirectory.RemoveAllChildren()
err = subdirectory.removeAllChildren(childPath)
subdirectory.Close()
if err != nil {
return err
}
}
err = d.Remove(component)
if err != nil {
return err
return util.StatusWrapf(err, "Failed to remove component %#v", childPath)
}
}
return nil
Expand Down