@@ -16,6 +16,7 @@ import (
16
16
17
17
"github.com/buildbarn/bb-storage/pkg/filesystem/path"
18
18
"github.com/buildbarn/bb-storage/pkg/filesystem/windowsext"
19
+ "github.com/buildbarn/bb-storage/pkg/util"
19
20
20
21
"golang.org/x/sys/windows"
21
22
"google.golang.org/grpc/codes"
@@ -586,32 +587,37 @@ func (d *localDirectory) Remove(name path.Component) error {
586
587
587
588
// On NTFS mount point is a reparse point, no need to unmount.
588
589
func (d * localDirectory ) RemoveAllChildren () error {
590
+ return d .removeAllChildren (nil )
591
+ }
592
+
593
+ func (d * localDirectory ) removeAllChildren (dPath * path.Trace ) error {
589
594
defer runtime .KeepAlive (d )
590
595
591
596
names , err := readdirnames (d .handle )
592
597
if err != nil {
593
- return err
598
+ return util . StatusWrapf ( err , "Failed to read contents of directory %#v" , dPath . GetUNIXString ())
594
599
}
595
600
for _ , name := range names {
596
601
component := path .MustNewComponent (name )
597
602
fileType , err := d .lstat (component )
603
+ childPath := dPath .Append (component )
598
604
if err != nil {
599
- return err
605
+ return util . StatusWrapf ( err , "Failed to stat %#v" , childPath . GetUNIXString ())
600
606
}
601
607
if fileType == FileTypeDirectory {
602
608
subdirectory , err := d .enter (component , true )
603
609
if err != nil {
604
- return err
610
+ return util . StatusWrapf ( err , "Failed to enter directory %#v" , childPath . GetUNIXString ())
605
611
}
606
- err = subdirectory .RemoveAllChildren ( )
612
+ err = subdirectory .removeAllChildren ( childPath )
607
613
subdirectory .Close ()
608
614
if err != nil {
609
615
return err
610
616
}
611
617
}
612
618
err = d .Remove (component )
613
619
if err != nil {
614
- return err
620
+ return util . StatusWrapf ( err , "Failed to remove %#v" , childPath . GetUNIXString ())
615
621
}
616
622
}
617
623
return nil
0 commit comments