Skip to content

Commit

Permalink
Implement file action remove for wildcards
Browse files Browse the repository at this point in the history
  • Loading branch information
hinshun committed Oct 29, 2019
1 parent 50a406a commit 15a7979
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions solver/llbsolver/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ func mkfile(ctx context.Context, d string, action pb.FileActionMkFile, user *cop
}

func rm(ctx context.Context, d string, action pb.FileActionRm) error {
if action.AllowWildcard {
src := cleanPath(action.Path)
m, err := copy.ResolveWildcards(d, src, false)
if err != nil {
return err
}

for _, s := range m {
p, err := fs.RootPath(d, filepath.Join(filepath.Join("/", s)))
if err != nil {
return err
}

if err := os.RemoveAll(p); err != nil {
return err
}
}

return nil
}

p, err := fs.RootPath(d, filepath.Join(filepath.Join("/", action.Path)))
if err != nil {
return err
Expand Down

0 comments on commit 15a7979

Please sign in to comment.